Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -35,10 +35,10 @@ def generate_speech(text, voice, speed):
|
|
35 |
# Save audio file
|
36 |
sf.write(output_path, audio, 24000)
|
37 |
|
38 |
-
return output_path
|
39 |
|
40 |
except Exception as e:
|
41 |
-
return None
|
42 |
|
43 |
def get_available_voices():
|
44 |
"""Get list of available voices from the model"""
|
@@ -77,7 +77,7 @@ with gr.Blocks(title="KittenTTS - Text to Speech", theme=gr.themes.Soft()) as ap
|
|
77 |
speed_slider = gr.Slider(
|
78 |
minimum=0.5,
|
79 |
maximum=2.0,
|
80 |
-
step=0.
|
81 |
value=1.25,
|
82 |
label="Speech Speed",
|
83 |
info="Adjust the speed of speech (0.5x to 2.0x)"
|
@@ -93,23 +93,18 @@ with gr.Blocks(title="KittenTTS - Text to Speech", theme=gr.themes.Soft()) as ap
|
|
93 |
interactive=False,
|
94 |
autoplay=True
|
95 |
)
|
96 |
-
|
97 |
-
status_output = gr.Textbox(
|
98 |
-
label="Status",
|
99 |
-
interactive=False,
|
100 |
-
lines=3
|
101 |
-
)
|
102 |
|
103 |
# Example inputs
|
104 |
gr.Markdown("## π Example Texts")
|
105 |
examples = gr.Examples(
|
106 |
examples=[
|
107 |
-
["Hello! This is a test of the KittenTTS model.", available_voices[
|
108 |
["The quick brown fox jumps over the lazy dog.", available_voices[1] if available_voices else "expr-voice-5-m", 1.5],
|
109 |
-
["Welcome to the world of high-quality text-to-speech synthesis!", available_voices[
|
110 |
],
|
111 |
inputs=[text_input, voice_dropdown, speed_slider],
|
112 |
-
label="Click on an example to try it out"
|
|
|
113 |
)
|
114 |
|
115 |
# Model information
|
@@ -137,16 +132,16 @@ with gr.Blocks(title="KittenTTS - Text to Speech", theme=gr.themes.Soft()) as ap
|
|
137 |
generate_btn.click(
|
138 |
fn=generate_speech,
|
139 |
inputs=[text_input, voice_dropdown, speed_slider],
|
140 |
-
outputs=[audio_output
|
141 |
)
|
142 |
|
143 |
# Auto-generate on Enter key (optional)
|
144 |
text_input.submit(
|
145 |
fn=generate_speech,
|
146 |
inputs=[text_input, voice_dropdown, speed_slider],
|
147 |
-
outputs=[audio_output
|
148 |
)
|
149 |
|
150 |
# Launch the app
|
151 |
if __name__ == "__main__":
|
152 |
-
app.launch()
|
|
|
35 |
# Save audio file
|
36 |
sf.write(output_path, audio, 24000)
|
37 |
|
38 |
+
return output_path
|
39 |
|
40 |
except Exception as e:
|
41 |
+
return None
|
42 |
|
43 |
def get_available_voices():
|
44 |
"""Get list of available voices from the model"""
|
|
|
77 |
speed_slider = gr.Slider(
|
78 |
minimum=0.5,
|
79 |
maximum=2.0,
|
80 |
+
step=0.01,
|
81 |
value=1.25,
|
82 |
label="Speech Speed",
|
83 |
info="Adjust the speed of speech (0.5x to 2.0x)"
|
|
|
93 |
interactive=False,
|
94 |
autoplay=True
|
95 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
# Example inputs
|
98 |
gr.Markdown("## π Example Texts")
|
99 |
examples = gr.Examples(
|
100 |
examples=[
|
101 |
+
["Hello! This is a test of the KittenTTS model.", available_voices[2] if available_voices else "expr-voice-5-m", 1.25],
|
102 |
["The quick brown fox jumps over the lazy dog.", available_voices[1] if available_voices else "expr-voice-5-m", 1.5],
|
103 |
+
["Welcome to the world of high-quality text-to-speech synthesis!", available_voices[5] if available_voices else "expr-voice-5-m", 1],
|
104 |
],
|
105 |
inputs=[text_input, voice_dropdown, speed_slider],
|
106 |
+
label="Click on an example to try it out",
|
107 |
+
cache_examples = False
|
108 |
)
|
109 |
|
110 |
# Model information
|
|
|
132 |
generate_btn.click(
|
133 |
fn=generate_speech,
|
134 |
inputs=[text_input, voice_dropdown, speed_slider],
|
135 |
+
outputs=[audio_output]
|
136 |
)
|
137 |
|
138 |
# Auto-generate on Enter key (optional)
|
139 |
text_input.submit(
|
140 |
fn=generate_speech,
|
141 |
inputs=[text_input, voice_dropdown, speed_slider],
|
142 |
+
outputs=[audio_output]
|
143 |
)
|
144 |
|
145 |
# Launch the app
|
146 |
if __name__ == "__main__":
|
147 |
+
app.launch(default_concurrency_limit=100)
|