Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ model = AutoModel.from_pretrained(
|
|
| 9 |
).to(device)
|
| 10 |
|
| 11 |
|
| 12 |
-
def generate_audio(text, speaker_id, temperature, cfg_strength, steps):
|
| 13 |
if not text or not text.strip():
|
| 14 |
return None
|
| 15 |
|
|
@@ -19,6 +19,7 @@ def generate_audio(text, speaker_id, temperature, cfg_strength, steps):
|
|
| 19 |
temperature=float(temperature),
|
| 20 |
cfg_strength=float(cfg_strength),
|
| 21 |
n_steps=int(steps),
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
audio_np = waveform.squeeze().cpu().numpy()
|
|
@@ -63,6 +64,13 @@ with gr.Blocks(
|
|
| 63 |
value=16,
|
| 64 |
label="Steps",
|
| 65 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
generate_btn = gr.Button("Generate", variant="primary")
|
| 68 |
|
|
@@ -77,6 +85,7 @@ with gr.Blocks(
|
|
| 77 |
temp_slider,
|
| 78 |
cfg_slider,
|
| 79 |
steps_slider,
|
|
|
|
| 80 |
],
|
| 81 |
outputs=audio_output,
|
| 82 |
)
|
|
@@ -89,6 +98,7 @@ with gr.Blocks(
|
|
| 89 |
0.667,
|
| 90 |
2.5,
|
| 91 |
16,
|
|
|
|
| 92 |
],
|
| 93 |
[
|
| 94 |
"The quick brown fox jumps over the lazy dog, running swiftly across the green fields.",
|
|
@@ -96,6 +106,7 @@ with gr.Blocks(
|
|
| 96 |
0.8,
|
| 97 |
1.5,
|
| 98 |
16,
|
|
|
|
| 99 |
],
|
| 100 |
[
|
| 101 |
"Did you know that sound waves travel through air at about three hundred and forty three meters per second? That is truly fascinating!",
|
|
@@ -103,6 +114,7 @@ with gr.Blocks(
|
|
| 103 |
0.8,
|
| 104 |
1.3,
|
| 105 |
24,
|
|
|
|
| 106 |
],
|
| 107 |
[
|
| 108 |
"You should look for a river if you get lost in the woods and watch which way it flows, then follow it. You see humans have always needed water for drinking and farming. So they would typically build towns along rivers, meaning following one might lead you back to civilization. But some rivers run through empty forests for miles, meaning you could be walking for a while.",
|
|
@@ -110,6 +122,7 @@ with gr.Blocks(
|
|
| 110 |
0.667,
|
| 111 |
2.0,
|
| 112 |
8,
|
|
|
|
| 113 |
],
|
| 114 |
],
|
| 115 |
inputs=[
|
|
@@ -118,6 +131,7 @@ with gr.Blocks(
|
|
| 118 |
temp_slider,
|
| 119 |
cfg_slider,
|
| 120 |
steps_slider,
|
|
|
|
| 121 |
],
|
| 122 |
fn=generate_audio,
|
| 123 |
outputs=audio_output,
|
|
|
|
| 9 |
).to(device)
|
| 10 |
|
| 11 |
|
| 12 |
+
def generate_audio(text, speaker_id, temperature, cfg_strength, steps, length_scale):
|
| 13 |
if not text or not text.strip():
|
| 14 |
return None
|
| 15 |
|
|
|
|
| 19 |
temperature=float(temperature),
|
| 20 |
cfg_strength=float(cfg_strength),
|
| 21 |
n_steps=int(steps),
|
| 22 |
+
length_scale=float(length_scale),
|
| 23 |
)
|
| 24 |
|
| 25 |
audio_np = waveform.squeeze().cpu().numpy()
|
|
|
|
| 64 |
value=16,
|
| 65 |
label="Steps",
|
| 66 |
)
|
| 67 |
+
speed_slider = gr.Slider(
|
| 68 |
+
minimum=0.5,
|
| 69 |
+
maximum=2.0,
|
| 70 |
+
step=0.05,
|
| 71 |
+
value=1.0,
|
| 72 |
+
label="Length Scale / Pace (<1.0 Fast, >1.0 Slow)",
|
| 73 |
+
)
|
| 74 |
|
| 75 |
generate_btn = gr.Button("Generate", variant="primary")
|
| 76 |
|
|
|
|
| 85 |
temp_slider,
|
| 86 |
cfg_slider,
|
| 87 |
steps_slider,
|
| 88 |
+
speed_slider,
|
| 89 |
],
|
| 90 |
outputs=audio_output,
|
| 91 |
)
|
|
|
|
| 98 |
0.667,
|
| 99 |
2.5,
|
| 100 |
16,
|
| 101 |
+
1.0,
|
| 102 |
],
|
| 103 |
[
|
| 104 |
"The quick brown fox jumps over the lazy dog, running swiftly across the green fields.",
|
|
|
|
| 106 |
0.8,
|
| 107 |
1.5,
|
| 108 |
16,
|
| 109 |
+
1.0,
|
| 110 |
],
|
| 111 |
[
|
| 112 |
"Did you know that sound waves travel through air at about three hundred and forty three meters per second? That is truly fascinating!",
|
|
|
|
| 114 |
0.8,
|
| 115 |
1.3,
|
| 116 |
24,
|
| 117 |
+
1.0,
|
| 118 |
],
|
| 119 |
[
|
| 120 |
"You should look for a river if you get lost in the woods and watch which way it flows, then follow it. You see humans have always needed water for drinking and farming. So they would typically build towns along rivers, meaning following one might lead you back to civilization. But some rivers run through empty forests for miles, meaning you could be walking for a while.",
|
|
|
|
| 122 |
0.667,
|
| 123 |
2.0,
|
| 124 |
8,
|
| 125 |
+
1.0,
|
| 126 |
],
|
| 127 |
],
|
| 128 |
inputs=[
|
|
|
|
| 131 |
temp_slider,
|
| 132 |
cfg_slider,
|
| 133 |
steps_slider,
|
| 134 |
+
speed_slider,
|
| 135 |
],
|
| 136 |
fn=generate_audio,
|
| 137 |
outputs=audio_output,
|