Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ UPLOAD_URL = os.getenv("UPLOAD_URL")
|
|
21 |
|
22 |
async def get_voices():
|
23 |
voices = await edge_tts.list_voices()
|
24 |
-
return [(voice
|
25 |
|
26 |
async def text_to_speech(voice_id, text, session_id):
|
27 |
communicate = edge_tts.Communicate(text, voice_id)
|
@@ -182,14 +182,14 @@ def create_interface():
|
|
182 |
|
183 |
async def on_generate(voice_name, video_url, text):
|
184 |
voices = await get_voices()
|
185 |
-
voice_id = next((v[
|
186 |
if not voice_id:
|
187 |
return None, "Invalid voice selected."
|
188 |
return await process_video(voice_id, video_url, text)
|
189 |
|
190 |
async def populate_voices():
|
191 |
voices = await get_voices()
|
192 |
-
return gr.Dropdown.update(choices=[v[
|
193 |
|
194 |
app.load(populate_voices, outputs=[voice_dropdown])
|
195 |
|
|
|
21 |
|
22 |
async def get_voices():
|
23 |
voices = await edge_tts.list_voices()
|
24 |
+
return [(voice['ShortName'], voice['Name']) for voice in voices]
|
25 |
|
26 |
async def text_to_speech(voice_id, text, session_id):
|
27 |
communicate = edge_tts.Communicate(text, voice_id)
|
|
|
182 |
|
183 |
async def on_generate(voice_name, video_url, text):
|
184 |
voices = await get_voices()
|
185 |
+
voice_id = next((v[0] for v in voices if v[1] == voice_name), None)
|
186 |
if not voice_id:
|
187 |
return None, "Invalid voice selected."
|
188 |
return await process_video(voice_id, video_url, text)
|
189 |
|
190 |
async def populate_voices():
|
191 |
voices = await get_voices()
|
192 |
+
return gr.Dropdown.update(choices=[v[1] for v in voices], value=voices[0][1] if voices else None)
|
193 |
|
194 |
app.load(populate_voices, outputs=[voice_dropdown])
|
195 |
|