Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -141,58 +141,48 @@ def generate_audio(tts_text, mode_checkbox_group, sft_dropdown, prompt_text, pro
|
|
141 |
audio_data = output['tts_speech'].numpy().flatten()
|
142 |
return (target_sr, audio_data)
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
-
if __name__ == '__main__':
|
185 |
-
parser = argparse.ArgumentParser()
|
186 |
-
parser.add_argument('--port',
|
187 |
-
type=int,
|
188 |
-
default=8000)
|
189 |
-
parser.add_argument('--model_dir',
|
190 |
-
type=str,
|
191 |
-
default='iic/CosyVoice-300M',
|
192 |
-
help='local path or modelscope repo id')
|
193 |
-
args = parser.parse_args()
|
194 |
-
cosyvoice = CosyVoice(args.model_dir)
|
195 |
-
sft_spk = cosyvoice.list_avaliable_spks()
|
196 |
-
prompt_sr, target_sr = 16000, 22050
|
197 |
-
default_data = np.zeros(target_sr)
|
198 |
-
main()
|
|
|
141 |
audio_data = output['tts_speech'].numpy().flatten()
|
142 |
return (target_sr, audio_data)
|
143 |
|
144 |
+
|
145 |
+
cosyvoice = CosyVoice('iic/CosyVoice-300M')
|
146 |
+
sft_spk = cosyvoice.list_avaliable_spks()
|
147 |
+
prompt_sr, target_sr = 16000, 22050
|
148 |
+
default_data = np.zeros(target_sr)
|
149 |
+
|
150 |
+
with gr.Blocks() as demo:
|
151 |
+
gr.Markdown("# <center>🌊💕🎶 [CosyVoice](https://www.bilibili.com/video/BV1vz421q7ir/) 3秒音频,开启最强声音复刻</center>")
|
152 |
+
gr.Markdown("## <center>🌟 只需3秒参考音频,一键开启超拟人真实声音复刻,支持中日英韩粤语,无需任何训练!</center>")
|
153 |
+
gr.Markdown("### <center>🤗 更多精彩,尽在[滔滔AI](https://www.talktalkai.com/);滔滔AI,为爱滔滔!💕</center>")
|
154 |
+
|
155 |
+
with gr.Row():
|
156 |
+
tts_text = gr.Textbox(label="请填写您希望声音复刻的文本内容", lines=3, info="中文文本建议不超过100个字,英文文本不超过100个单词", placeholder="想说却还没说的,还很多...")
|
157 |
+
mode_checkbox_group = gr.Radio(choices=inference_mode_list, label='请选择声音复刻类型', value=inference_mode_list[0], info="如果声音复刻的文本和参考音频对应的文本是同一种语言,请选择“3s极速复刻”;不同语言,请选“跨语种复刻”")
|
158 |
+
instruction_text = gr.Text(label="📔 操作指南", value=instruct_dict[inference_mode_list[0]], scale=0.5, visible=False)
|
159 |
+
sft_dropdown = gr.Dropdown(choices=sft_spk, label='选择预训练音色', value=sft_spk[0], scale=0.25, visible=False)
|
160 |
+
with gr.Column(scale=0.25):
|
161 |
+
seed_button = gr.Button(value="\U0001F3B2", visible=True)
|
162 |
+
seed = gr.Number(value=0, label="随机推理种子", info="若数值保持不变,则每次生成结果一致", visible=True)
|
163 |
+
|
164 |
+
with gr.Row():
|
165 |
+
prompt_text = gr.Textbox(label="请填写参考音频对应的文本内容", lines=3, placeholder="告诉我参考音频说了些什么吧...")
|
166 |
+
prompt_wav_upload = gr.Audio(type='filepath', label='请从本地上传您喜欢的参考音频,注意采样率不低于16kHz')
|
167 |
+
prompt_wav_record = gr.Audio(type='filepath', label='通过麦克风录制参考音频,程序会优先使用本地上传的参考音频', visible=False)
|
168 |
+
generate_button = gr.Button("一键开启声音复刻💕", variant="primary")
|
169 |
+
instruct_text = gr.Textbox(label="输入instruct文本", lines=1, placeholder="请输入instruct文本.", value='', visible=False)
|
170 |
+
|
171 |
+
|
172 |
+
audio_output = gr.Audio(label="为您生成的专属音频🎶")
|
173 |
+
|
174 |
+
seed_button.click(fn=generate_seed, inputs=[], outputs=seed)
|
175 |
+
generate_button.click(fn=generate_audio,
|
176 |
+
inputs=[tts_text, mode_checkbox_group, sft_dropdown, prompt_text, prompt_wav_upload, prompt_wav_record, instruct_text, seed],
|
177 |
+
outputs=[audio_output])
|
178 |
+
mode_checkbox_group.change(fn=change_instruction, inputs=[mode_checkbox_group], outputs=[instruction_text])
|
179 |
+
gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。请自觉合规使用此程序,程序开发者不负有任何责任。</center>")
|
180 |
+
gr.HTML('''
|
181 |
+
<div class="footer">
|
182 |
+
<p>🌊🏞️🎶 - 江水东流急,滔滔无尽声。 明·顾璘
|
183 |
+
</p>
|
184 |
+
</div>
|
185 |
+
''')
|
186 |
+
demo.queue(max_size=40, api_open=False)
|
187 |
+
demo.launch(max_threads=400, show_error=True)
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|