Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,23 +74,8 @@ def soprano_tts(
|
|
| 74 |
raise gr.Error(f"Error during speech generation: {str(e)[:200]}...")
|
| 75 |
|
| 76 |
|
| 77 |
-
def save_audio(audio_np: np.ndarray | None) -> str | None:
|
| 78 |
-
"""Save audio to a temporary WAV file for download."""
|
| 79 |
-
if audio_np is None or len(audio_np) == 0:
|
| 80 |
-
return None
|
| 81 |
-
if wav_write is None:
|
| 82 |
-
raise gr.Error("scipy is not installed. Please run: pip install scipy")
|
| 83 |
-
import os
|
| 84 |
-
fd, path = tempfile.mkstemp(suffix=".wav")
|
| 85 |
-
os.close(fd)
|
| 86 |
-
wav_write(path, SAMPLE_RATE, audio_np)
|
| 87 |
-
return path
|
| 88 |
-
|
| 89 |
-
|
| 90 |
# --- Gradio UI ---
|
| 91 |
with gr.Blocks() as demo:
|
| 92 |
-
state_audio = gr.State(None)
|
| 93 |
-
|
| 94 |
gr.HTML("<h1 style='text-align: center;'>Soprano-TTS</h1><p style='text-align: center;'>Powered by Soprano-80M | 32kHz High-Fidelity Audio</p>")
|
| 95 |
|
| 96 |
with gr.Row(variant="panel"):
|
|
@@ -136,36 +121,21 @@ with gr.Blocks() as demo:
|
|
| 136 |
autoplay=True,
|
| 137 |
)
|
| 138 |
|
| 139 |
-
download_btn = gr.Button("Download Audio")
|
| 140 |
-
download_file = gr.File(label="Download")
|
| 141 |
-
|
| 142 |
generate_inputs = [text_input, temperature, top_p, repetition_penalty]
|
| 143 |
|
| 144 |
-
def generate_and_store(text, temperature, top_p, repetition_penalty):
|
| 145 |
-
result = soprano_tts(text, temperature, top_p, repetition_penalty)
|
| 146 |
-
if result:
|
| 147 |
-
return result, result[1] # Return audio tuple and numpy array for state
|
| 148 |
-
return None, None
|
| 149 |
-
|
| 150 |
generate_btn.click(
|
| 151 |
-
fn=
|
| 152 |
inputs=generate_inputs,
|
| 153 |
-
outputs=
|
| 154 |
api_name="generate_speech",
|
| 155 |
)
|
| 156 |
|
| 157 |
text_input.submit(
|
| 158 |
-
fn=
|
| 159 |
inputs=generate_inputs,
|
| 160 |
-
outputs=
|
| 161 |
api_name="generate_speech_enter",
|
| 162 |
)
|
| 163 |
|
| 164 |
-
download_btn.click(
|
| 165 |
-
fn=save_audio,
|
| 166 |
-
inputs=[state_audio],
|
| 167 |
-
outputs=[download_file],
|
| 168 |
-
)
|
| 169 |
-
|
| 170 |
if __name__ == "__main__":
|
| 171 |
demo.queue().launch(debug=True, theme="Nymbo/Nymbo_Theme")
|
|
|
|
| 74 |
raise gr.Error(f"Error during speech generation: {str(e)[:200]}...")
|
| 75 |
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
# --- Gradio UI ---
|
| 78 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 79 |
gr.HTML("<h1 style='text-align: center;'>Soprano-TTS</h1><p style='text-align: center;'>Powered by Soprano-80M | 32kHz High-Fidelity Audio</p>")
|
| 80 |
|
| 81 |
with gr.Row(variant="panel"):
|
|
|
|
| 121 |
autoplay=True,
|
| 122 |
)
|
| 123 |
|
|
|
|
|
|
|
|
|
|
| 124 |
generate_inputs = [text_input, temperature, top_p, repetition_penalty]
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
generate_btn.click(
|
| 127 |
+
fn=soprano_tts,
|
| 128 |
inputs=generate_inputs,
|
| 129 |
+
outputs=audio_output,
|
| 130 |
api_name="generate_speech",
|
| 131 |
)
|
| 132 |
|
| 133 |
text_input.submit(
|
| 134 |
+
fn=soprano_tts,
|
| 135 |
inputs=generate_inputs,
|
| 136 |
+
outputs=audio_output,
|
| 137 |
api_name="generate_speech_enter",
|
| 138 |
)
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
if __name__ == "__main__":
|
| 141 |
demo.queue().launch(debug=True, theme="Nymbo/Nymbo_Theme")
|