ayousanz commited on
Commit
3275e74
·
verified ·
1 Parent(s): c25402c

Update from GitHub Actions - 2025-08-21 08:28:42

Browse files
Files changed (3) hide show
  1. README.md +5 -2
  2. app.py +79 -27
  3. requirements.txt +2 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🎙️
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.44.1
8
  app_file: app.py
9
  pinned: false
10
  license: mit
@@ -64,4 +64,7 @@ python app.py
64
 
65
  ## License
66
 
67
- This project is licensed under the MIT License. See the original [Piper repository](https://github.com/rhasspy/piper) for more details.
 
 
 
 
4
  colorFrom: blue
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.50.2
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
64
 
65
  ## License
66
 
67
+ This project is licensed under the MIT License. See the original [Piper repository](https://github.com/rhasspy/piper) for more details.
68
+
69
+ ---
70
+ _Last updated: 2025-01-21 - Cache rebuild for Gradio 3.50.2_
app.py CHANGED
@@ -185,47 +185,45 @@ def synthesize_speech(
185
 
186
  def create_interface():
187
  """Create Gradio interface"""
 
 
 
 
188
 
189
- with gr.Blocks(title="Piper TTS Demo") as interface:
190
- gr.Markdown("""
191
- # 🎙️ Piper TTS Demo
192
-
193
- High-quality text-to-speech synthesis supporting Japanese and English.
194
 
195
- This demo uses ONNX models for fast CPU inference.
196
- """)
197
 
198
- with gr.Row():
199
- with gr.Column(scale=2):
200
- model_dropdown = gr.Dropdown(
201
- choices=list(MODELS.keys()),
202
- label="Select Model",
203
- value=list(MODELS.keys())[0],
204
- )
205
 
206
- text_input = gr.Textbox(
207
- label="Text to synthesize",
208
- placeholder="Enter text here...",
209
- lines=3,
210
- )
211
 
212
- with gr.Accordion("Advanced Settings", open=False):
 
 
213
  speaker_id = gr.Number(
214
- label="Speaker ID",
215
  value=0,
216
  precision=0,
217
- minimum=0,
218
- maximum=10,
219
- info="For multi-speaker models only",
220
  )
221
 
222
  length_scale = gr.Slider(
223
- label="Speed",
224
  minimum=0.5,
225
  maximum=2.0,
226
  value=1.0,
227
  step=0.1,
228
- info="Lower = faster speech",
229
  )
230
 
231
  noise_scale = gr.Slider(
@@ -292,6 +290,43 @@ def create_interface():
292
  outputs=audio_output,
293
  )
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  return interface
296
 
297
 
@@ -299,4 +334,21 @@ def create_interface():
299
  interface = create_interface()
300
 
301
  if __name__ == "__main__":
302
- interface.launch(server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
 
186
  def create_interface():
187
  """Create Gradio interface"""
188
+ try:
189
+ with gr.Blocks(title="Piper TTS Demo") as interface:
190
+ gr.Markdown("""
191
+ # 🎙️ Piper TTS Demo
192
 
193
+ High-quality text-to-speech synthesis supporting Japanese and English.
 
 
 
 
194
 
195
+ This demo uses ONNX models for fast CPU inference.
196
+ """)
197
 
198
+ with gr.Row():
199
+ with gr.Column(scale=2):
200
+ model_dropdown = gr.Dropdown(
201
+ choices=list(MODELS.keys()),
202
+ label="Select Model",
203
+ value=list(MODELS.keys())[0],
204
+ )
205
 
206
+ text_input = gr.Textbox(
207
+ label="Text to synthesize",
208
+ placeholder="Enter text here...",
209
+ lines=3,
210
+ )
211
 
212
+ # Advanced Settings without Accordion (flattened)
213
+ gr.Markdown("### Advanced Settings")
214
+
215
  speaker_id = gr.Number(
216
+ label="Speaker ID (for multi-speaker models)",
217
  value=0,
218
  precision=0,
 
 
 
219
  )
220
 
221
  length_scale = gr.Slider(
222
+ label="Speed (Lower = faster speech)",
223
  minimum=0.5,
224
  maximum=2.0,
225
  value=1.0,
226
  step=0.1,
 
227
  )
228
 
229
  noise_scale = gr.Slider(
 
290
  outputs=audio_output,
291
  )
292
 
293
+ return interface
294
+ except Exception as e:
295
+ logger.error(f"Failed to create main interface: {e}")
296
+ # Fallback to minimal interface
297
+ return create_minimal_interface()
298
+
299
+
300
+ def create_minimal_interface():
301
+ """Create a minimal fallback interface if main interface fails"""
302
+ with gr.Blocks(title="Piper TTS Demo - Minimal") as interface:
303
+ gr.Markdown("# Piper TTS Demo (Minimal Mode)")
304
+
305
+ text_input = gr.Textbox(
306
+ label="Text to synthesize",
307
+ placeholder="Enter text here...",
308
+ lines=3,
309
+ )
310
+
311
+ model_dropdown = gr.Dropdown(
312
+ choices=list(MODELS.keys()),
313
+ label="Select Model",
314
+ value=list(MODELS.keys())[0],
315
+ )
316
+
317
+ synthesize_btn = gr.Button("Generate Speech", variant="primary")
318
+
319
+ audio_output = gr.Audio(
320
+ label="Generated Speech",
321
+ type="numpy",
322
+ )
323
+
324
+ synthesize_btn.click(
325
+ fn=lambda text, model: synthesize_speech(text, model, 0, 1.0, 0.667, 0.8),
326
+ inputs=[text_input, model_dropdown],
327
+ outputs=audio_output,
328
+ )
329
+
330
  return interface
331
 
332
 
 
334
  interface = create_interface()
335
 
336
  if __name__ == "__main__":
337
+ try:
338
+ # Launch with minimal settings for Gradio 3.x
339
+ interface.launch(
340
+ server_name="0.0.0.0",
341
+ server_port=7860,
342
+ show_api=False, # Disable API documentation
343
+ show_error=True,
344
+ quiet=False,
345
+ )
346
+ except Exception as e:
347
+ logger.error(f"Failed to launch interface: {e}")
348
+ # Try minimal launch
349
+ minimal_interface = create_minimal_interface()
350
+ minimal_interface.launch(
351
+ server_name="0.0.0.0",
352
+ server_port=7860,
353
+ show_api=False,
354
+ )
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  # Piper TTS Demo Requirements
2
- gradio==4.42.0 # Downgraded from 4.44.1 to avoid json_schema_to_python_type bug
 
3
  numpy>=1.24.0,<3.0
4
  onnxruntime>=1.16.0
5
  pyopenjtalk>=0.3.0
 
1
  # Piper TTS Demo Requirements
2
+ gradio==3.50.2 # Stable Gradio 3.x version to avoid TypeError
3
+ pydantic==1.10.18 # Compatible with Gradio 3.x
4
  numpy>=1.24.0,<3.0
5
  onnxruntime>=1.16.0
6
  pyopenjtalk>=0.3.0