Spaces:
Runtime error
Runtime error
Commit
·
39ccbcc
1
Parent(s):
7a2bce5
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,14 @@ base_speaker_tts.load_ckpt(f'{ckpt_base_en}/checkpoint.pth')
|
|
| 15 |
tone_color_converter = ToneColorConverter(f'{ckpt_converter_en}/config.json', device=device)
|
| 16 |
tone_color_converter.load_ckpt(f'{ckpt_converter_en}/checkpoint.pth')
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
from tts_voice import tts_order_voice
|
| 19 |
import edge_tts
|
| 20 |
import gradio as gr
|
|
@@ -63,6 +71,26 @@ def vc_en(text, audio_ref, style_mode):
|
|
| 63 |
|
| 64 |
return "output.wav"
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
language_dict = tts_order_voice
|
| 67 |
|
| 68 |
base_speaker = "base_audio.mp3"
|
|
@@ -109,11 +137,23 @@ with app:
|
|
| 109 |
with gr.Column():
|
| 110 |
out1 = gr.Audio(label="为您合成的专属语音", type="filepath")
|
| 111 |
btn1.click(vc_en, [inp1, inp2, inp3], out1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
with gr.Tab("🌟多语言声音复刻"):
|
| 114 |
with gr.Row():
|
| 115 |
with gr.Column():
|
| 116 |
-
inp4 = gr.Textbox(lines=3, label="
|
| 117 |
inp5 = gr.Audio(label="请上传您喜欢的语音文件", type="filepath")
|
| 118 |
inp6 = gr.Dropdown(choices=list(language_dict.keys()), value=list(language_dict.keys())[15], label="请选择文本对应的语言")
|
| 119 |
|
|
|
|
| 15 |
tone_color_converter = ToneColorConverter(f'{ckpt_converter_en}/config.json', device=device)
|
| 16 |
tone_color_converter.load_ckpt(f'{ckpt_converter_en}/checkpoint.pth')
|
| 17 |
|
| 18 |
+
ckpt_base_zh = 'checkpoints/checkpoints/base_speakers/ZH'
|
| 19 |
+
base_speaker_tts_zh = BaseSpeakerTTS(f'{ckpt_base_zh}/config.json', device=device)
|
| 20 |
+
base_speaker_tts_zh.load_ckpt(f'{ckpt_base_zh}/checkpoint.pth')
|
| 21 |
+
|
| 22 |
+
source_se = torch.load(f'{ckpt_base}/zh_default_se.pth').to(device)
|
| 23 |
+
save_path = f'{output_dir}/output_chinese.wav'
|
| 24 |
+
|
| 25 |
+
|
| 26 |
from tts_voice import tts_order_voice
|
| 27 |
import edge_tts
|
| 28 |
import gradio as gr
|
|
|
|
| 71 |
|
| 72 |
return "output.wav"
|
| 73 |
|
| 74 |
+
def vc_zh(text, audio_ref):
|
| 75 |
+
source_se = torch.load(f'{ckpt_base}/zh_default_se.pth').to(device)
|
| 76 |
+
save_path = "output.wav"
|
| 77 |
+
src_path = "tmp.wav"
|
| 78 |
+
base_speaker_tts.tts(text, src_path, speaker='default', language='Chinese', speed=1.0)
|
| 79 |
+
|
| 80 |
+
reference_speaker = audio_ref
|
| 81 |
+
target_se, audio_name = se_extractor.get_se(reference_speaker, tone_color_converter, target_dir='processed', vad=True)
|
| 82 |
+
|
| 83 |
+
# Run the tone color converter
|
| 84 |
+
encode_message = "@MyShell"
|
| 85 |
+
tone_color_converter.convert(
|
| 86 |
+
audio_src_path=src_path,
|
| 87 |
+
src_se=source_se,
|
| 88 |
+
tgt_se=target_se,
|
| 89 |
+
output_path=save_path,
|
| 90 |
+
message=encode_message)
|
| 91 |
+
return "output.wav"
|
| 92 |
+
|
| 93 |
+
|
| 94 |
language_dict = tts_order_voice
|
| 95 |
|
| 96 |
base_speaker = "base_audio.mp3"
|
|
|
|
| 137 |
with gr.Column():
|
| 138 |
out1 = gr.Audio(label="为您合成的专属语音", type="filepath")
|
| 139 |
btn1.click(vc_en, [inp1, inp2, inp3], out1)
|
| 140 |
+
|
| 141 |
+
with gr.Tab("🎶中文声音复刻"):
|
| 142 |
+
with gr.Row():
|
| 143 |
+
with gr.Column():
|
| 144 |
+
inp_zh_1 = gr.Textbox(lines=3, label="请输入您想转换的中文文本")
|
| 145 |
+
inp_zh_2 = gr.Audio(label="请上传您喜欢的语音文件", type="filepath")
|
| 146 |
+
|
| 147 |
+
btn_zh = gr.Button("开始语音情感真实复刻吧!", variant="primary")
|
| 148 |
+
|
| 149 |
+
with gr.Column():
|
| 150 |
+
out_zh = gr.Audio(label="为您合成的专属语音", type="filepath")
|
| 151 |
+
btn_zh.click(vc_zh, [inp_zh_1, inp_zh_2], out_zh)
|
| 152 |
|
| 153 |
with gr.Tab("🌟多语言声音复刻"):
|
| 154 |
with gr.Row():
|
| 155 |
with gr.Column():
|
| 156 |
+
inp4 = gr.Textbox(lines=3, label="请输入您想转换的任意语言文本")
|
| 157 |
inp5 = gr.Audio(label="请上传您喜欢的语音文件", type="filepath")
|
| 158 |
inp6 = gr.Dropdown(choices=list(language_dict.keys()), value=list(language_dict.keys())[15], label="请选择文本对应的语言")
|
| 159 |
|