Commit 61c8721d authored by chenpangpang's avatar chenpangpang
Browse files

feat: 修改gradio需要的模型、依赖库、语言

parent 655551cc
Pipeline #1458 canceled with stages
FROM image.sourcefind.cn:5000/gpu/admin/base/jupyterlab-pytorch:2.2.0-python3.10-cuda12.1-ubuntu22.04 as base
ARG IMAGE=voice-clone
ARG IMAGE_UPPER=voice-clone
ARG BRANCH=gpu
RUN cd /root && git clone -b $BRANCH http://developer.hpccube.com/codes/chenpangpang/$IMAGE.git
WORKDIR /root/$IMAGE/$IMAGE_UPPER
RUN pip install -r requirements.txt
#########
# Prod #
#########
FROM image.sourcefind.cn:5000/gpu/admin/base/jupyterlab-pytorch:2.2.0-python3.10-cuda12.1-ubuntu22.04
ARG IMAGE=voice-clone
ARG IMAGE_UPPER=voice-clone
COPY chenyh/$IMAGE/frpc_linux_amd64_v0.2 /opt/conda/lib/python3.10/site-packages/gradio/
RUN chmod +x /opt/conda/lib/python3.10/site-packages/gradio/frpc_linux_amd64_v0.2
COPY chenyh/$IMAGE/coqui/XTTS-v2 /root/.local/share/tts/tts_models--multilingual--multi-dataset--xtts_v2
COPY --from=base /opt/conda/lib/python3.10/site-packages /opt/conda/lib/python3.10/site-packages
COPY --from=base /root/$IMAGE/$IMAGE_UPPER /root/$IMAGE_UPPER
COPY --from=base /root/$IMAGE/启动器.ipynb /root/$IMAGE/start.sh /root/
\ No newline at end of file
import spaces
import gradio as gr import gradio as gr
import torch import torch
from TTS.api import TTS from TTS.api import TTS
...@@ -11,7 +10,6 @@ device = "cuda" ...@@ -11,7 +10,6 @@ device = "cuda"
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device) tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(device)
@spaces.GPU(enable_queue=True)
def clone(text, audio, language): def clone(text, audio, language):
tts.tts_to_file(text=text, speaker_wav=audio, language=language, file_path="./output.wav") tts.tts_to_file(text=text, speaker_wav=audio, language=language, file_path="./output.wav")
return "./output.wav" return "./output.wav"
...@@ -21,10 +19,12 @@ iface = gr.Interface(fn=clone, ...@@ -21,10 +19,12 @@ iface = gr.Interface(fn=clone,
inputs=[gr.Textbox(label='Text'), inputs=[gr.Textbox(label='Text'),
gr.Audio(type='filepath', label='Voice reference audio file'), gr.Audio(type='filepath', label='Voice reference audio file'),
gr.Dropdown(label='Language', gr.Dropdown(label='Language',
choices=['en - English', 'fr - French', 'ar - Arabic', 'es - Spanish', # choices=['en - English', 'fr - French', 'ar - Arabic', 'es - Spanish',
'zh - Chinese', 'ru - Russian', 'pt - Portuguese', 'it - Italian', # 'zh - Chinese', 'ru - Russian', 'pt - Portuguese', 'it - Italian',
'de - German', 'nl - Dutch'])], # 'de - German', 'nl - Dutch'])],
outputs=gr.Audio(type='filepath'), choices=['en', 'es', 'fr', 'de', 'it', 'pt', 'pl', 'tr', 'ru', 'nl', 'cs',
'ar', 'zh-cn', 'hu', 'ko', 'ja', 'hi'])],
outputs=gr.Audio(type='filepath', label='Generated audio file'),
title='Voice Clone', title='Voice Clone',
description=""" description="""
by [Tony Assi](https://www.tonyassi.com/) by [Tony Assi](https://www.tonyassi.com/)
...@@ -43,4 +43,4 @@ iface = gr.Interface(fn=clone, ...@@ -43,4 +43,4 @@ iface = gr.Interface(fn=clone,
"./audio/Megan-Fox.mp3", "en - English"], "./audio/Megan-Fox.mp3", "en - English"],
["Hey there, it's me Jeff Goldblum. Type in whatever you'd like me to say.", ["Hey there, it's me Jeff Goldblum. Type in whatever you'd like me to say.",
"./audio/Jeff-Goldblum.mp3", "en - English"], ]) "./audio/Jeff-Goldblum.mp3", "en - English"], ])
iface.launch() iface.launch(server_name='0.0.0.0', share=True)
\ No newline at end of file
TTS TTS
torch torch
gradio==4.26.0
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment