Spaces:
Running on Zero
Running on Zero
Download app.py from Praieiro/Prometheus: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Praieiro/Prometheus/resolve/main/app.py
- Command line
-
hf download hf://spaces/Praieiro/Prometheus/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Praieiro/Prometheus/resolve/main/app.py
1.5 kB
| import io | |
| import os | |
| import soundfile as sf | |
| import gradio as gr | |
| import spaces | |
| from huggingface_hub import hf_hub_download | |
| from f5_tts.api import F5TTS | |
| REF_AUDIO_PATH = "PraieiroVox.wav" | |
| f5tts_instance = None | |
| def get_model(): | |
| global f5tts_instance | |
| if f5tts_instance is None: | |
| print("Carregando modelo F5-TTS pt-br na GPU...") | |
| ckpt = hf_hub_download("firstpixel/F5-TTS-pt-br", "pt-br/model_last.safetensors") | |
| f5tts_instance = F5TTS(model="F5TTS_Base", ckpt_file=ckpt, device="cuda") | |
| return f5tts_instance | |
| def clone_voice(text: str): | |
| if not text or not text.strip(): | |
| return None | |
| model = get_model() | |
| wav, sr, _ = model.infer( | |
| ref_file=REF_AUDIO_PATH, | |
| ref_text="", | |
| gen_text=text.strip(), | |
| remove_silence=True, | |
| ) | |
| return sr, wav | |
| with gr.Blocks(title="Praieiro Vox · Clonagem de Voz") as demo: | |
| gr.Markdown("# 🌊 Praieiro Vox · Voz Oficial do Praieiro Bot") | |
| gr.Markdown("Motor de clonagem F5-TTS (pt-BR) rodando na GPU do Praieiro.") | |
| text_input = gr.Textbox( | |
| label="Texto a ser falado", | |
| value="Fala meu brother! Seu pedido na praia já tá sendo preparado e chega voando!", | |
| lines=3, | |
| ) | |
| btn = gr.Button("🎤 Gerar Fala com a Voz Clonada", variant="primary") | |
| audio_output = gr.Audio(label="Áudio Gerado", type="numpy") | |
| btn.click(fn=clone_voice, inputs=[text_input], outputs=[audio_output], api_name="clone_voice") | |
| demo.launch() | |