Update app.py
Browse files
app.py
CHANGED
|
@@ -259,20 +259,31 @@ async def generate_video():
|
|
| 259 |
if voice_cloning == 'no':
|
| 260 |
if voice_gender == 'male':
|
| 261 |
voice = 'echo'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
else:
|
| 263 |
voice = 'nova'
|
| 264 |
|
| 265 |
-
|
| 266 |
-
|
| 267 |
voice=voice,
|
| 268 |
input = text_prompt)
|
| 269 |
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
|
| 274 |
-
|
| 275 |
-
|
| 276 |
|
| 277 |
elif voice_cloning == 'yes':
|
| 278 |
user_voice = request.files['user_voice']
|
|
|
|
| 259 |
if voice_cloning == 'no':
|
| 260 |
if voice_gender == 'male':
|
| 261 |
voice = 'echo'
|
| 262 |
+
print('Entering Audio creation using elevenlabs')
|
| 263 |
+
set_api_key("87792fce164425fbe1204e9fd1fe25cd")
|
| 264 |
+
|
| 265 |
+
audio = generate(text = text_prompt, voice = "Daniel", model = "eleven_multilingual_v2",stream=True, latency=4)
|
| 266 |
+
with tempfile.NamedTemporaryFile(suffix=".mp3", prefix="text_to_speech_",dir=TEMP_DIR.name, delete=False) as temp_file:
|
| 267 |
+
for chunk in audio:
|
| 268 |
+
temp_file.write(chunk)
|
| 269 |
+
driven_audio_path = temp_file.name
|
| 270 |
+
print('driven_audio_path',driven_audio_path)
|
| 271 |
+
print('Audio file saved using elevenlabs')
|
| 272 |
+
|
| 273 |
else:
|
| 274 |
voice = 'nova'
|
| 275 |
|
| 276 |
+
print('Entering Audio creation using whisper')
|
| 277 |
+
response = client.audio.speech.create(model="tts-1-hd",
|
| 278 |
voice=voice,
|
| 279 |
input = text_prompt)
|
| 280 |
|
| 281 |
+
print('Audio created using whisper')
|
| 282 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", prefix="text_to_speech_",dir=TEMP_DIR.name, delete=False) as temp_file:
|
| 283 |
+
driven_audio_path = temp_file.name
|
| 284 |
|
| 285 |
+
response.write_to_file(driven_audio_path)
|
| 286 |
+
print('Audio file saved using whisper')
|
| 287 |
|
| 288 |
elif voice_cloning == 'yes':
|
| 289 |
user_voice = request.files['user_voice']
|