Spaces:
Running
Running
update the UI default values
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ logger = logging.get_logger(__name__)
|
|
| 16 |
|
| 17 |
|
| 18 |
|
|
|
|
| 19 |
model_local_dir= str(cached_path("hf://microsoft/VibeVoice-1.5B"))
|
| 20 |
#model_local_dir= "./ckpts/vibevoice"
|
| 21 |
#snapshot_download(repo_id="microsoft/VibeVoice-1.5B", local_dir=model_local_dir)
|
|
@@ -59,8 +60,8 @@ def create_demo_interface(demo_instance: VibeVoiceDemo):
|
|
| 59 |
num_speakers = gr.Slider(
|
| 60 |
minimum=1,
|
| 61 |
maximum=4,
|
| 62 |
-
value=2,
|
| 63 |
step=1,
|
|
|
|
| 64 |
label="Number of Speakers",
|
| 65 |
elem_classes="slider-container"
|
| 66 |
)
|
|
@@ -80,12 +81,12 @@ def create_demo_interface(demo_instance: VibeVoiceDemo):
|
|
| 80 |
choices=available_speaker_names,
|
| 81 |
value=default_value,
|
| 82 |
label=f"Speaker {i+1}",
|
| 83 |
-
visible=(i <
|
| 84 |
elem_classes="speaker-item"
|
| 85 |
)
|
| 86 |
speaker_selections.append(speaker)
|
| 87 |
|
| 88 |
-
with gr.Accordion("🎤 Upload Custom Voices", open=
|
| 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])
|
|
@@ -258,10 +259,10 @@ Or paste text directly and it will auto-assign speakers.""",
|
|
| 258 |
else:
|
| 259 |
# Streaming state: update streaming audio only
|
| 260 |
if streaming_audio is not None:
|
| 261 |
-
yield streaming_audio,
|
| 262 |
else:
|
| 263 |
# No new audio, just update status
|
| 264 |
-
yield None,
|
| 265 |
|
| 266 |
except Exception as e:
|
| 267 |
error_msg = f"❌ A critical error occurred in the wrapper: {str(e)}"
|
|
@@ -280,7 +281,7 @@ Or paste text directly and it will auto-assign speakers.""",
|
|
| 280 |
# Add a clear audio function
|
| 281 |
def clear_audio_outputs():
|
| 282 |
"""Clear both audio outputs before starting new generation."""
|
| 283 |
-
return None,
|
| 284 |
|
| 285 |
# Connect generation button with streaming outputs
|
| 286 |
generate_btn.click(
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
+
DEFAULT_NUM_SPEAKERS = 1
|
| 20 |
model_local_dir= str(cached_path("hf://microsoft/VibeVoice-1.5B"))
|
| 21 |
#model_local_dir= "./ckpts/vibevoice"
|
| 22 |
#snapshot_download(repo_id="microsoft/VibeVoice-1.5B", local_dir=model_local_dir)
|
|
|
|
| 60 |
num_speakers = gr.Slider(
|
| 61 |
minimum=1,
|
| 62 |
maximum=4,
|
|
|
|
| 63 |
step=1,
|
| 64 |
+
value=DEFAULT_NUM_SPEAKERS,
|
| 65 |
label="Number of Speakers",
|
| 66 |
elem_classes="slider-container"
|
| 67 |
)
|
|
|
|
| 81 |
choices=available_speaker_names,
|
| 82 |
value=default_value,
|
| 83 |
label=f"Speaker {i+1}",
|
| 84 |
+
visible=(i < DEFAULT_NUM_SPEAKERS), # Initially show only first 2 speakers
|
| 85 |
elem_classes="speaker-item"
|
| 86 |
)
|
| 87 |
speaker_selections.append(speaker)
|
| 88 |
|
| 89 |
+
with gr.Accordion("🎤 Upload Custom Voices", open=True):
|
| 90 |
upload_audio = gr.File(label="Upload Voice Samples", file_count="multiple", file_types=["audio"])
|
| 91 |
process_upload_btn = gr.Button("Add Uploaded Voices to Speaker Selection")
|
| 92 |
process_upload_btn.click(fn=process_and_refresh_voices, inputs=upload_audio, outputs=speaker_selections + [upload_audio])
|
|
|
|
| 259 |
else:
|
| 260 |
# Streaming state: update streaming audio only
|
| 261 |
if streaming_audio is not None:
|
| 262 |
+
yield streaming_audio, None, log, streaming_visible, gr.update(visible=False), gr.update(visible=True)
|
| 263 |
else:
|
| 264 |
# No new audio, just update status
|
| 265 |
+
yield None, None, log, streaming_visible, gr.update(visible=False), gr.update(visible=True)
|
| 266 |
|
| 267 |
except Exception as e:
|
| 268 |
error_msg = f"❌ A critical error occurred in the wrapper: {str(e)}"
|
|
|
|
| 281 |
# Add a clear audio function
|
| 282 |
def clear_audio_outputs():
|
| 283 |
"""Clear both audio outputs before starting new generation."""
|
| 284 |
+
return None, None
|
| 285 |
|
| 286 |
# Connect generation button with streaming outputs
|
| 287 |
generate_btn.click(
|