Spaces:
Running
Running
feat: add functionality to upload and refresh custom voice samples in demo interface
Browse files
app.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
VibeVoice Gradio Demo - High-Quality Dialogue Generation Interface with Streaming Support
|
| 3 |
"""
|
| 4 |
|
| 5 |
-
import argparse
|
|
|
|
| 6 |
import torch
|
| 7 |
import gradio as gr
|
| 8 |
|
|
@@ -44,6 +45,14 @@ def create_demo_interface(demo_instance: VibeVoiceDemo):
|
|
| 44 |
with gr.Row():
|
| 45 |
# Left column - Settings
|
| 46 |
with gr.Column(scale=1, elem_classes="settings-card"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
gr.Markdown("### 🎛️ **Podcast Settings**")
|
| 48 |
|
| 49 |
# Number of speakers
|
|
@@ -75,7 +84,13 @@ def create_demo_interface(demo_instance: VibeVoiceDemo):
|
|
| 75 |
elem_classes="speaker-item"
|
| 76 |
)
|
| 77 |
speaker_selections.append(speaker)
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
# Advanced settings
|
| 80 |
gr.Markdown("### ⚙️ **Advanced Settings**")
|
| 81 |
|
|
|
|
| 2 |
VibeVoice Gradio Demo - High-Quality Dialogue Generation Interface with Streaming Support
|
| 3 |
"""
|
| 4 |
|
| 5 |
+
import argparse, os
|
| 6 |
+
import tempfile
|
| 7 |
import torch
|
| 8 |
import gradio as gr
|
| 9 |
|
|
|
|
| 45 |
with gr.Row():
|
| 46 |
# Left column - Settings
|
| 47 |
with gr.Column(scale=1, elem_classes="settings-card"):
|
| 48 |
+
|
| 49 |
+
def process_and_refresh_voices(uploaded_files: list[tempfile._TemporaryFileWrapper]):
|
| 50 |
+
if not uploaded_files: return [gr.update() for _ in speaker_selections] + [None]
|
| 51 |
+
for f in uploaded_files:
|
| 52 |
+
demo_instance.available_voices[os.path.basename(f.name)] = f.name
|
| 53 |
+
new_choices = list(demo_instance.available_voices.keys())
|
| 54 |
+
return [gr.update(choices=new_choices) for _ in speaker_selections] + [None]
|
| 55 |
+
|
| 56 |
gr.Markdown("### 🎛️ **Podcast Settings**")
|
| 57 |
|
| 58 |
# Number of speakers
|
|
|
|
| 84 |
elem_classes="speaker-item"
|
| 85 |
)
|
| 86 |
speaker_selections.append(speaker)
|
| 87 |
+
|
| 88 |
+
with gr.Accordion("🎤 Upload Custom Voices", open=False):
|
| 89 |
+
upload_audio = gr.File(label="Upload Voice Samples", file_count="multiple", file_types=["audio"])
|
| 90 |
+
process_upload_btn = gr.Button("Add Uploaded Voices to Speaker Selection")
|
| 91 |
+
process_upload_btn.click(fn=process_and_refresh_voices, inputs=upload_audio, outputs=speaker_selections + [upload_audio])
|
| 92 |
+
|
| 93 |
+
|
| 94 |
# Advanced settings
|
| 95 |
gr.Markdown("### ⚙️ **Advanced Settings**")
|
| 96 |
|