Spaces:
Runtime error
Runtime error
Commit ·
cb1e3b7
1
Parent(s): 42fe613
hopefuly
Browse files- src/predict.py +14 -3
src/predict.py
CHANGED
|
@@ -289,9 +289,20 @@ class Predictor:
|
|
| 289 |
reference_speaker = local_file_path
|
| 290 |
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, target_dir=openvoice_dir, vad=False)
|
| 291 |
src_path = os.path.join(results_dir,f"{gen_id}-tmp.wav")
|
| 292 |
-
openvoice_output = os.path.join(results_dir,f"{gen_id}-voice-clone-
|
| 293 |
-
|
| 294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
|
| 297 |
def predict_with_multi_lang(self,s3_url,passage,process_audio):
|
|
|
|
| 289 |
reference_speaker = local_file_path
|
| 290 |
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, target_dir=openvoice_dir, vad=False)
|
| 291 |
src_path = os.path.join(results_dir,f"{gen_id}-tmp.wav")
|
| 292 |
+
openvoice_output = os.path.join(results_dir,f"{gen_id}-voice-clone-emotions.wav")
|
| 293 |
+
print("extracting emotions from openai")
|
| 294 |
+
base_speaker_tts.tts(passage,src_path,speaker='default',language='English',speed=1.0,use_emotions=True)
|
| 295 |
+
source_se, audio_name = se_extractor.get_se(src_path, tone_color_converter, target_dir=openvoice_dir, vad=False)
|
| 296 |
+
tone_color_converter.convert(audio_src_path=src_path,src_se=source_se,tgt_se=target_se,output_path=openvoice_output,message='')
|
| 297 |
+
if process_audio:
|
| 298 |
+
(new_sr, wav1) = self._fn(openvoice_output,"Midpoint",32,0.5)
|
| 299 |
+
sf.write(openvoice_output,wav1,new_sr)
|
| 300 |
+
mp3_final_output_2 = str(openvoice_output).replace('wav','mp3')
|
| 301 |
+
self.convert_wav_to_mp3(openvoice_output,mp3_final_output_2)
|
| 302 |
+
self.upload_file_to_s3(mp3_final_output_2,'demovidelyusergenerations',f"{gen_id}-voice-clone-emotions.mp3")
|
| 303 |
+
shutil.rmtree(os.path.join(output_dir,gen_id))
|
| 304 |
+
return {"voice_clone_emotions":f"https://demovidelyusergenerations.s3.amazonaws.com/{gen_id}-voice-clone-emotions.mp3",
|
| 305 |
+
}
|
| 306 |
|
| 307 |
|
| 308 |
def predict_with_multi_lang(self,s3_url,passage,process_audio):
|