Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,40 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
gr.Markdown("Hi everyone, due to breaking changes with ZeroGPU/Xet-storage spaces, this space is temporarily down. I hope to find a solution to this soon, so please stay tuned. Sorry for the inconvenience. In the mean time, please check out: https://huggingface.co/spaces/mrfakename/MegaTTS3-Voice-Cloning https://huggingface.co/spaces/styletts2/styletts2 if you need TTS spaces.")
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from f5_tts.infer.utils_infer import remove_silence_for_generated_wav
|
| 3 |
+
from demo_f5tts import F5TTS # assuming your F5TTS class is saved in demo_f5tts.py
|
| 4 |
+
import tempfile
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
+
f5tts = F5TTS()
|
|
|
|
| 8 |
|
| 9 |
+
def run_tts(ref_audio, ref_text, gen_text, remove_silence=False):
|
| 10 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_ref:
|
| 11 |
+
tmp_ref.write(ref_audio.read())
|
| 12 |
+
tmp_ref_path = tmp_ref.name
|
| 13 |
+
|
| 14 |
+
output_wav_path = tempfile.mktemp(suffix=".wav")
|
| 15 |
+
|
| 16 |
+
wav, sr, _ = f5tts.infer(
|
| 17 |
+
ref_file=tmp_ref_path,
|
| 18 |
+
ref_text=ref_text,
|
| 19 |
+
gen_text=gen_text,
|
| 20 |
+
file_wave=output_wav_path,
|
| 21 |
+
remove_silence=remove_silence,
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
return output_wav_path
|
| 25 |
+
|
| 26 |
+
demo = gr.Interface(
|
| 27 |
+
fn=run_tts,
|
| 28 |
+
inputs=[
|
| 29 |
+
gr.Audio(label="Reference Audio", type="binary"),
|
| 30 |
+
gr.Textbox(label="Reference Text", placeholder="some call me nature, others call me mother nature."),
|
| 31 |
+
gr.Textbox(label="Generation Text", placeholder="I don't really care what you call me..."),
|
| 32 |
+
gr.Checkbox(label="Remove Silence from Output?", value=False)
|
| 33 |
+
],
|
| 34 |
+
outputs=gr.Audio(label="Generated Speech"),
|
| 35 |
+
title="🗣️ F5-TTS Demo",
|
| 36 |
+
description="Upload a reference voice, give reference and generation text, and hear it in the same voice!",
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
if __name__ == "__main__":
|
| 40 |
+
demo.launch()
|