Spaces:
Running
Running
Update from GitHub Actions - 2025-08-21 14:44:46
Browse files
app.py
CHANGED
|
@@ -300,9 +300,8 @@ def synthesize_speech(
|
|
| 300 |
|
| 301 |
def create_interface():
|
| 302 |
"""Create Gradio interface"""
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
gr.Markdown("""
|
| 306 |
# 🎙️ Piper TTS Demo
|
| 307 |
|
| 308 |
High-quality text-to-speech synthesis supporting Japanese and English.
|
|
@@ -310,64 +309,64 @@ def create_interface():
|
|
| 310 |
This demo uses ONNX models for fast CPU inference.
|
| 311 |
""")
|
| 312 |
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
)
|
| 344 |
-
|
| 345 |
-
noise_scale = gr.Slider(
|
| 346 |
-
label="Expressiveness",
|
| 347 |
-
minimum=0.0,
|
| 348 |
-
maximum=1.0,
|
| 349 |
-
value=0.667,
|
| 350 |
-
step=0.01,
|
| 351 |
-
)
|
| 352 |
-
|
| 353 |
-
noise_w = gr.Slider(
|
| 354 |
-
label="Phoneme Duration Variance",
|
| 355 |
-
minimum=0.0,
|
| 356 |
-
maximum=1.0,
|
| 357 |
-
value=0.8,
|
| 358 |
-
step=0.01,
|
| 359 |
-
)
|
| 360 |
-
|
| 361 |
-
synthesize_btn = gr.Button("Generate Speech", variant="primary")
|
| 362 |
-
|
| 363 |
-
with gr.Column(scale=1):
|
| 364 |
-
audio_output = gr.Audio(
|
| 365 |
-
label="Generated Speech",
|
| 366 |
-
type="numpy",
|
| 367 |
-
autoplay=True,
|
| 368 |
)
|
| 369 |
|
| 370 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
### Tips:
|
| 372 |
- Japanese model expects hiragana/kanji text
|
| 373 |
- English model works with standard text
|
|
@@ -406,17 +405,13 @@ def create_interface():
|
|
| 406 |
outputs=audio_output,
|
| 407 |
)
|
| 408 |
|
| 409 |
-
|
| 410 |
-
except Exception as e:
|
| 411 |
-
logger.error(f"Failed to create main interface: {e}")
|
| 412 |
-
# Fallback to minimal interface
|
| 413 |
-
return create_minimal_interface()
|
| 414 |
|
| 415 |
|
| 416 |
def create_minimal_interface():
|
| 417 |
"""Create a minimal fallback interface if main interface fails"""
|
| 418 |
-
with gr.Blocks(title="Piper TTS Demo
|
| 419 |
-
gr.Markdown("# Piper TTS Demo
|
| 420 |
|
| 421 |
text_input = gr.Textbox(
|
| 422 |
label="Text to synthesize",
|
|
@@ -451,22 +446,10 @@ def create_minimal_interface():
|
|
| 451 |
interface = None
|
| 452 |
|
| 453 |
if __name__ == "__main__":
|
| 454 |
-
# Create
|
| 455 |
interface = create_interface()
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
server_port=7860,
|
| 462 |
-
show_api=False, # Disable API documentation for cleaner UI
|
| 463 |
-
)
|
| 464 |
-
except Exception as e:
|
| 465 |
-
logger.error(f"Failed to launch interface: {e}")
|
| 466 |
-
# Try minimal launch
|
| 467 |
-
minimal_interface = create_minimal_interface()
|
| 468 |
-
minimal_interface.launch(
|
| 469 |
-
server_name="0.0.0.0",
|
| 470 |
-
server_port=7860,
|
| 471 |
-
show_api=False,
|
| 472 |
-
)
|
|
|
|
| 300 |
|
| 301 |
def create_interface():
|
| 302 |
"""Create Gradio interface"""
|
| 303 |
+
with gr.Blocks(title="Piper TTS Demo") as interface:
|
| 304 |
+
gr.Markdown("""
|
|
|
|
| 305 |
# 🎙️ Piper TTS Demo
|
| 306 |
|
| 307 |
High-quality text-to-speech synthesis supporting Japanese and English.
|
|
|
|
| 309 |
This demo uses ONNX models for fast CPU inference.
|
| 310 |
""")
|
| 311 |
|
| 312 |
+
with gr.Row():
|
| 313 |
+
with gr.Column(scale=2):
|
| 314 |
+
model_dropdown = gr.Dropdown(
|
| 315 |
+
choices=list(MODELS.keys()),
|
| 316 |
+
label="Select Model",
|
| 317 |
+
value=list(MODELS.keys())[0],
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
text_input = gr.Textbox(
|
| 321 |
+
label="Text to synthesize",
|
| 322 |
+
placeholder="Enter text here...",
|
| 323 |
+
lines=3,
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
# Advanced Settings without Accordion (flattened)
|
| 327 |
+
gr.Markdown("### Advanced Settings")
|
| 328 |
+
|
| 329 |
+
speaker_id = gr.Number(
|
| 330 |
+
label="Speaker ID (for multi-speaker models)",
|
| 331 |
+
value=0,
|
| 332 |
+
minimum=0,
|
| 333 |
+
maximum=10,
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
length_scale = gr.Slider(
|
| 337 |
+
label="Speed (Lower = faster speech)",
|
| 338 |
+
minimum=0.5,
|
| 339 |
+
maximum=2.0,
|
| 340 |
+
value=1.0,
|
| 341 |
+
step=0.1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
)
|
| 343 |
|
| 344 |
+
noise_scale = gr.Slider(
|
| 345 |
+
label="Expressiveness",
|
| 346 |
+
minimum=0.0,
|
| 347 |
+
maximum=1.0,
|
| 348 |
+
value=0.667,
|
| 349 |
+
step=0.01,
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
noise_w = gr.Slider(
|
| 353 |
+
label="Phoneme Duration Variance",
|
| 354 |
+
minimum=0.0,
|
| 355 |
+
maximum=1.0,
|
| 356 |
+
value=0.8,
|
| 357 |
+
step=0.01,
|
| 358 |
+
)
|
| 359 |
+
|
| 360 |
+
synthesize_btn = gr.Button("Generate Speech", variant="primary")
|
| 361 |
+
|
| 362 |
+
with gr.Column(scale=1):
|
| 363 |
+
audio_output = gr.Audio(
|
| 364 |
+
label="Generated Speech",
|
| 365 |
+
type="numpy",
|
| 366 |
+
autoplay=True,
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
gr.Markdown("""
|
| 370 |
### Tips:
|
| 371 |
- Japanese model expects hiragana/kanji text
|
| 372 |
- English model works with standard text
|
|
|
|
| 405 |
outputs=audio_output,
|
| 406 |
)
|
| 407 |
|
| 408 |
+
return interface
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
|
| 410 |
|
| 411 |
def create_minimal_interface():
|
| 412 |
"""Create a minimal fallback interface if main interface fails"""
|
| 413 |
+
with gr.Blocks(title="Piper TTS Demo") as interface:
|
| 414 |
+
gr.Markdown("# 🎙️ Piper TTS Demo")
|
| 415 |
|
| 416 |
text_input = gr.Textbox(
|
| 417 |
label="Text to synthesize",
|
|
|
|
| 446 |
interface = None
|
| 447 |
|
| 448 |
if __name__ == "__main__":
|
| 449 |
+
# Create and launch interface
|
| 450 |
interface = create_interface()
|
| 451 |
+
interface.launch(
|
| 452 |
+
server_name="0.0.0.0",
|
| 453 |
+
server_port=7860,
|
| 454 |
+
show_api=False, # Disable API documentation for cleaner UI
|
| 455 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|