BoldActionMan
commited on
Commit
•
7ce119a
1
Parent(s):
c00e8d2
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import torch
|
|
6 |
from openvoice import se_extractor
|
7 |
from openvoice.api import ToneColorConverter
|
8 |
import whisper
|
9 |
-
from moviepy import *
|
10 |
from pydub import AudioSegment
|
11 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
12 |
import translators as ts
|
@@ -52,7 +52,7 @@ def process_video(video_file, language_choice):
|
|
52 |
audio = AudioSegment.from_file(reference_audio)
|
53 |
resampled_audio = audio.set_frame_rate(48000)
|
54 |
resampled_audio.export(reference_audio, format="wav")
|
55 |
-
|
56 |
|
57 |
# Enhance the audio
|
58 |
model, df_state, _ = init_df()
|
@@ -159,8 +159,9 @@ def process_video(video_file, language_choice):
|
|
159 |
segment_path = os.path.join(output_dir, f'segment_{start}_{end}.wav')
|
160 |
model.tts_to_file(translated_text, speaker_id, segment_path, speed=speed)
|
161 |
|
162 |
-
reference_speaker =
|
163 |
-
|
|
|
164 |
# Run the tone color converter
|
165 |
encode_message = "@MyShell"
|
166 |
tone_color_converter.convert(
|
|
|
6 |
from openvoice import se_extractor
|
7 |
from openvoice.api import ToneColorConverter
|
8 |
import whisper
|
9 |
+
from moviepy.editor import *
|
10 |
from pydub import AudioSegment
|
11 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
12 |
import translators as ts
|
|
|
52 |
audio = AudioSegment.from_file(reference_audio)
|
53 |
resampled_audio = audio.set_frame_rate(48000)
|
54 |
resampled_audio.export(reference_audio, format="wav")
|
55 |
+
audio_clip = AudioFileClip(reference_audio)
|
56 |
|
57 |
# Enhance the audio
|
58 |
model, df_state, _ = init_df()
|
|
|
159 |
segment_path = os.path.join(output_dir, f'segment_{start}_{end}.wav')
|
160 |
model.tts_to_file(translated_text, speaker_id, segment_path, speed=speed)
|
161 |
|
162 |
+
reference_speaker = AudioFileClip.subclip(audio_clip, int(start), int(end)) # This is the voice you want to clone
|
163 |
+
reference_speaker.write_audiofile("reference_speaker.wav")
|
164 |
+
target_se, audio_name = se_extractor.get_se("reference_speaker.wav", tone_color_converter, vad=False)
|
165 |
# Run the tone color converter
|
166 |
encode_message = "@MyShell"
|
167 |
tone_color_converter.convert(
|