Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -88,18 +88,46 @@ VOICE_EXAMPLES = {
|
|
| 88 |
"落ち着いた男性 / 呆れ気味": "落ち着いた低めの声の男性が、相手の言動に少し呆れつつも感情を表に出さず、静かで平坦なトーンで淡々と話してるような声で読んでほしい。", # https://huggingface.co/spaces/Respair/Voice_Design/blob/main/samples/guy_cool.wav
|
| 89 |
"Calm man / mildly exasperated (EN)": "Read this in the voice of a calm, low-pitched man who sounds mildly exasperated but keeps his emotions in check, speaking in a flat, even tone without much expression.", # Nothing
|
| 90 |
"冷たい女性 / 憎しみ (1)": "低くて冷たい声の女性が、怒りを内に秘めながら憎しみのこもった口調で、淡々と早めに話してるような声で読んでほしい。", # https://huggingface.co/spaces/Respair/Voice_Design/blob/main/samples/woman_cold_frustrated_2.wav
|
| 91 |
-
"冷たい女性 / 憎しみ (2)": "低くて冷たい声の女性が、怒りを内に秘めながら憎しみのこもった口調で、淡々と早めに話してるような声で読んでほしい。", # same text different result
|
| 92 |
}
|
| 93 |
|
| 94 |
VOICE_PRESET_LIST = list(VOICE_EXAMPLES.items())
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
def run_generation_pipeline_client(
|
|
@@ -164,7 +192,6 @@ with gr.Blocks(theme="Respair/Shiki@10.1.0", css=css) as demo:
|
|
| 164 |
</div>
|
| 165 |
"""
|
| 166 |
)
|
| 167 |
-
|
| 168 |
with gr.Tabs():
|
| 169 |
|
| 170 |
with gr.TabItem("Speech Generation"):
|
|
@@ -254,11 +281,11 @@ with gr.Blocks(theme="Respair/Shiki@10.1.0", css=css) as demo:
|
|
| 254 |
concurrency_limit=4,
|
| 255 |
)
|
| 256 |
|
| 257 |
-
with gr.TabItem("
|
| 258 |
gr.HTML("""
|
| 259 |
<div style="background-color: rgba(255, 255, 255, 0.025); padding: 20px; border-radius: 12px; backdrop-filter: blur(10px); box-shadow: 0 4px 6px rgba(0,0,0,0.5); margin-top: 8px;">
|
| 260 |
<p style="color: #1a1a1a; font-weight: 500; line-height: 1.6; font-size: 14px; text-align: center; margin: 0;">
|
| 261 |
-
|
| 262 |
</p>
|
| 263 |
</div>
|
| 264 |
""")
|
|
@@ -270,39 +297,19 @@ with gr.Blocks(theme="Respair/Shiki@10.1.0", css=css) as demo:
|
|
| 270 |
<h3 style="color: #000000; margin: 0; font-size: 16px;">Examples</h3>
|
| 271 |
</div>
|
| 272 |
""")
|
| 273 |
-
|
|
|
|
| 274 |
gr.Examples(
|
| 275 |
-
examples=[[label] for label in
|
| 276 |
-
inputs=[
|
| 277 |
-
outputs=[voice_desc_input],
|
| 278 |
-
fn=
|
| 279 |
-
label="Click to load a
|
| 280 |
cache_examples=False,
|
| 281 |
run_on_click=True,
|
| 282 |
examples_per_page=10,
|
| 283 |
)
|
| 284 |
|
| 285 |
-
gr.HTML("""
|
| 286 |
-
<div style="background-color: rgba(255, 255, 255, 0.025); padding: 20px; border-radius: 12px; backdrop-filter: blur(10px); box-shadow: 0 4px 6px rgba(0,0,0,0.5); margin-top: 16px;">
|
| 287 |
-
<p style="color: #1a1a1a; font-weight: 500; line-height: 1.6; font-size: 14px; text-align: center; margin: 0;">
|
| 288 |
-
クリックするとプリジェネ音声がロードされます。 / Click a preset to load a pre-generated audio sample.
|
| 289 |
-
</p>
|
| 290 |
-
</div>
|
| 291 |
-
""")
|
| 292 |
-
|
| 293 |
-
sample_holder = gr.Textbox(visible=False)
|
| 294 |
-
pregenerated_audio = gr.Audio(label="Pre-generated Samples", interactive=False)
|
| 295 |
-
gr.Examples(
|
| 296 |
-
examples=[[name] for name, _ in PREGENERATED_SAMPLES],
|
| 297 |
-
inputs=[sample_holder],
|
| 298 |
-
outputs=[pregenerated_audio],
|
| 299 |
-
fn=lambda name: next((path for n, path in PREGENERATED_SAMPLES if n == name), None),
|
| 300 |
-
label="Click to load a pre-generated sample",
|
| 301 |
-
cache_examples=False,
|
| 302 |
-
run_on_click=True,
|
| 303 |
-
examples_per_page=10,
|
| 304 |
-
)
|
| 305 |
-
|
| 306 |
with gr.TabItem("Info"):
|
| 307 |
gr.HTML('<h1 style="text-align: center;">🌸 Takane - Voice Design 🎨 </h1>')
|
| 308 |
|
|
|
|
| 88 |
"落ち着いた男性 / 呆れ気味": "落ち着いた低めの声の男性が、相手の言動に少し呆れつつも感情を表に出さず、静かで平坦なトーンで淡々と話してるような声で読んでほしい。", # https://huggingface.co/spaces/Respair/Voice_Design/blob/main/samples/guy_cool.wav
|
| 89 |
"Calm man / mildly exasperated (EN)": "Read this in the voice of a calm, low-pitched man who sounds mildly exasperated but keeps his emotions in check, speaking in a flat, even tone without much expression.", # Nothing
|
| 90 |
"冷たい女性 / 憎しみ (1)": "低くて冷たい声の女性が、怒りを内に秘めながら憎しみのこもった口調で、淡々と早めに話してるような声で読んでほしい。", # https://huggingface.co/spaces/Respair/Voice_Design/blob/main/samples/woman_cold_frustrated_2.wav
|
| 91 |
+
"冷たい女性 / 憎しみ (2)": "低くて冷たい声の女性が、怒りを内に秘めながら憎しみのこもった口調で、淡々と早めに話してるような声で読んでほしい。", # same text different result --> https://huggingface.co/spaces/Respair/Voice_Design/blob/main/samples/woman_cold_frustrated.wav
|
| 92 |
}
|
| 93 |
|
| 94 |
VOICE_PRESET_LIST = list(VOICE_EXAMPLES.items())
|
| 95 |
|
| 96 |
+
# label -> local file path (ship these in your Space repo under samples/)
|
| 97 |
+
PREGENERATED_AUDIO = {
|
| 98 |
+
"甘えた女の子 / ゆっくり": "samples/onnanoko_amai.wav",
|
| 99 |
+
"激怒する女性 / 感情爆発": "samples/angry.wav",
|
| 100 |
+
"落ち着いた男性 / 呆れ気味": "samples/guy_cool.wav",
|
| 101 |
+
"冷たい女性 / 憎しみ (1)": "samples/woman_cold_frustrated_2.wav",
|
| 102 |
+
"冷たい女性 / 憎しみ (2)": "samples/woman_cold_frustrated.wav",
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
def load_pregenerated_to_main(label):
|
| 106 |
+
"""
|
| 107 |
+
Click handler from Examples tab:
|
| 108 |
+
loads instruction text into the Instruction box (optional)
|
| 109 |
+
and loads the pre-generated WAV into the MAIN tab audio_output.
|
| 110 |
+
"""
|
| 111 |
+
desc = VOICE_EXAMPLES.get(label, "")
|
| 112 |
+
path = PREGENERATED_AUDIO.get(label)
|
| 113 |
+
|
| 114 |
+
if path and os.path.exists(path):
|
| 115 |
+
sr, data = wavfile.read(path)
|
| 116 |
+
|
| 117 |
+
if isinstance(data, np.ndarray) and data.ndim == 2 and data.shape[0] in (1, 2) and data.shape[0] < data.shape[1]:
|
| 118 |
+
data = data.T
|
| 119 |
+
|
| 120 |
+
return (
|
| 121 |
+
gr.update(value=desc), # voice_desc_input
|
| 122 |
+
(sr, data), # audio_output (MAIN TAB)
|
| 123 |
+
f"Status: Loaded pre-generated sample: {label}"
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
return (
|
| 127 |
+
gr.update(value=desc),
|
| 128 |
+
None,
|
| 129 |
+
f"Status: No pre-generated audio found for: {label}"
|
| 130 |
+
)
|
| 131 |
|
| 132 |
|
| 133 |
def run_generation_pipeline_client(
|
|
|
|
| 192 |
</div>
|
| 193 |
"""
|
| 194 |
)
|
|
|
|
| 195 |
with gr.Tabs():
|
| 196 |
|
| 197 |
with gr.TabItem("Speech Generation"):
|
|
|
|
| 281 |
concurrency_limit=4,
|
| 282 |
)
|
| 283 |
|
| 284 |
+
with gr.TabItem("Examples"):
|
| 285 |
gr.HTML("""
|
| 286 |
<div style="background-color: rgba(255, 255, 255, 0.025); padding: 20px; border-radius: 12px; backdrop-filter: blur(10px); box-shadow: 0 4px 6px rgba(0,0,0,0.5); margin-top: 8px;">
|
| 287 |
<p style="color: #1a1a1a; font-weight: 500; line-height: 1.6; font-size: 14px; text-align: center; margin: 0;">
|
| 288 |
+
クリックするとメインタブの音声プレイヤーにプリジェネ音声がロードされます。 / Click a preset to load the pre-generated audio into the main tab player.
|
| 289 |
</p>
|
| 290 |
</div>
|
| 291 |
""")
|
|
|
|
| 297 |
<h3 style="color: #000000; margin: 0; font-size: 16px;">Examples</h3>
|
| 298 |
</div>
|
| 299 |
""")
|
| 300 |
+
example_label_holder = gr.Textbox(visible=False)
|
| 301 |
+
|
| 302 |
gr.Examples(
|
| 303 |
+
examples=[[label] for label in PREGENERATED_AUDIO.keys()],
|
| 304 |
+
inputs=[example_label_holder],
|
| 305 |
+
outputs=[voice_desc_input, audio_output, status_output], # <-- MAIN TAB outputs
|
| 306 |
+
fn=load_pregenerated_to_main,
|
| 307 |
+
label="Click to load a pre-generated sample",
|
| 308 |
cache_examples=False,
|
| 309 |
run_on_click=True,
|
| 310 |
examples_per_page=10,
|
| 311 |
)
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
with gr.TabItem("Info"):
|
| 314 |
gr.HTML('<h1 style="text-align: center;">🌸 Takane - Voice Design 🎨 </h1>')
|
| 315 |
|