|
Great! Here's how to deploy your OpenVoice-based Gradio app on Hugging Face Spaces using Docker. |
|
|
|
|
|
--- |
|
|
|
1. Directory Structure |
|
|
|
openvoice-gradio-app/ |
|
βββ app.py |
|
βββ Dockerfile |
|
βββ requirements.txt |
|
βββ README.md (optional) |
|
|
|
|
|
--- |
|
|
|
2. app.py |
|
|
|
Here's a minimal Gradio interface using OpenVoice: |
|
|
|
import gradio as gr |
|
from openvoice import OpenVoice |
|
|
|
|
|
model = OpenVoice(language="en") |
|
|
|
def clone_and_speak(audio, text): |
|
output_path = "output.wav" |
|
model.clone_voice( |
|
source_audio_path=audio.name, |
|
target_text=text, |
|
output_path=output_path |
|
) |
|
return output_path |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# OpenVoice TTS - Hugging Face Space") |
|
with gr.Row(): |
|
audio_input = gr.Audio(label="Upload voice to clone", type="file") |
|
text_input = gr.Textbox(label="Enter text to synthesize") |
|
with gr.Row(): |
|
generate_btn = gr.Button("Generate Audio") |
|
audio_output = gr.Audio(label="Synthesized Output", type="filepath") |
|
|
|
generate_btn.click(fn=clone_and_speak, inputs=[audio_input, text_input], outputs=audio_output) |
|
|
|
demo.launch() |
|
|
|
|
|
--- |
|
|
|
3. requirements.txt |
|
|
|
List all necessary dependencies: |
|
|
|
gradio |
|
torch |
|
transformers |
|
numpy |
|
|
|
|
|
|
|
|
|
--- |
|
|
|
4. Dockerfile |
|
|
|
|
|
FROM python:3.10-slim |
|
|
|
|
|
RUN apt-get update && apt-get install -y ffmpeg git && rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
WORKDIR /app |
|
|
|
|
|
COPY . . |
|
|
|
|
|
RUN pip install --upgrade pip |
|
RUN pip install -r requirements.txt |
|
|
|
|
|
RUN git clone https://github.com/myshell-ai/OpenVoice.git && \ |
|
pip install -e OpenVoice |
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
CMD ["python", "app.py"] |
|
|
|
|
|
--- |
|
|
|
5. Push to Hugging Face Spaces |
|
|
|
1. Create a new Space on Hugging Face. |
|
|
|
|
|
2. Set SDK to Docker. |
|
|
|
|
|
3. Push your files to the linked repo via Git. |
|
|
|
|
|
|
|
git init |
|
git remote add origin https://huggingface.co/spaces/your-username/openvoice-gradio-app |
|
git add . |
|
git commit -m "Initial commit" |
|
git push -u origin main |
|
|
|
|
|
--- |
|
|
|
Let me know if OpenVoice needs special model download steps or GPU setup. I can adjust the Dockerfile accordingly. Would you like GPU support included? |
|
|
|
|