Spaces:
Running
Running
jonathanagustin
commited on
Commit
•
1a29ae8
1
Parent(s):
e847c01
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import tempfile
|
|
3 |
import openai
|
4 |
import requests
|
5 |
import os
|
|
|
6 |
|
7 |
|
8 |
def tts(input_text: str, model: str, voice: str, api_key: str) -> str:
|
@@ -104,20 +105,25 @@ def main():
|
|
104 |
|
105 |
# Wrap the voice previews inside an Accordion that is closed by default
|
106 |
with gr.Accordion(label="Voice Previews", open=False):
|
|
|
|
|
|
|
|
|
|
|
107 |
for voice in VOICE_OPTIONS:
|
108 |
-
#
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
with gr.Column(scale=2):
|
123 |
input_textbox = gr.Textbox(
|
|
|
3 |
import openai
|
4 |
import requests
|
5 |
import os
|
6 |
+
from functools import partial
|
7 |
|
8 |
|
9 |
def tts(input_text: str, model: str, voice: str, api_key: str) -> str:
|
|
|
105 |
|
106 |
# Wrap the voice previews inside an Accordion that is closed by default
|
107 |
with gr.Accordion(label="Voice Previews", open=False):
|
108 |
+
# Create an audio component to play the samples
|
109 |
+
preview_audio = gr.Audio(
|
110 |
+
interactive=False, label="Preview Audio", value=None
|
111 |
+
)
|
112 |
+
|
113 |
for voice in VOICE_OPTIONS:
|
114 |
+
# Create a button for each voice
|
115 |
+
voice_button = gr.Button(
|
116 |
+
value=f"▶ {voice.capitalize()}", variant="secondary"
|
117 |
+
)
|
118 |
+
|
119 |
+
# Define the handler function for this voice using partial
|
120 |
+
def play_voice_sample(voice):
|
121 |
+
return VOICE_PREVIEW_FILES[voice]
|
122 |
+
|
123 |
+
voice_handler = partial(play_voice_sample, voice)
|
124 |
+
|
125 |
+
# Attach the click handler
|
126 |
+
voice_button.click(fn=voice_handler, outputs=preview_audio)
|
127 |
|
128 |
with gr.Column(scale=2):
|
129 |
input_textbox = gr.Textbox(
|