Spaces:
Runtime error
Runtime error
wenmengzhou
commited on
Commit
•
73c1b13
1
Parent(s):
94b950a
Update css/custom.py
Browse files- css/custom.py +9 -0
css/custom.py
CHANGED
@@ -14,6 +14,8 @@ def custom():
|
|
14 |
@spaces.GPU
|
15 |
def generate_audio(_recorded_audio, _prompt_input_textbox, _language_radio,
|
16 |
_synthetic_input_textbox, _seed):
|
|
|
|
|
17 |
print(_recorded_audio, _prompt_input_textbox, _language_radio, _synthetic_input_textbox, _seed)
|
18 |
if _synthetic_input_textbox == '':
|
19 |
gr.Warning('合成文本为空,您是否忘记输入合成文本?')
|
@@ -24,11 +26,18 @@ def custom():
|
|
24 |
else:
|
25 |
model = cosyvoice
|
26 |
prompt_speech_16k = postprocess(load_wav(_recorded_audio, prompt_sr))
|
|
|
27 |
if _language_radio == 'cross' or _prompt_input_textbox == '':
|
28 |
output = model.inference_cross_lingual(_synthetic_input_textbox, prompt_speech_16k)
|
29 |
else:
|
30 |
output = model.inference_zero_shot(_synthetic_input_textbox, _prompt_input_textbox, prompt_speech_16k)
|
|
|
|
|
31 |
audio_data = postprocess(output['tts_speech']).numpy().flatten()
|
|
|
|
|
|
|
|
|
32 |
return (target_sr, audio_data)
|
33 |
|
34 |
with gr.Column():
|
|
|
14 |
@spaces.GPU
|
15 |
def generate_audio(_recorded_audio, _prompt_input_textbox, _language_radio,
|
16 |
_synthetic_input_textbox, _seed):
|
17 |
+
import time
|
18 |
+
t1 = time.time()
|
19 |
print(_recorded_audio, _prompt_input_textbox, _language_radio, _synthetic_input_textbox, _seed)
|
20 |
if _synthetic_input_textbox == '':
|
21 |
gr.Warning('合成文本为空,您是否忘记输入合成文本?')
|
|
|
26 |
else:
|
27 |
model = cosyvoice
|
28 |
prompt_speech_16k = postprocess(load_wav(_recorded_audio, prompt_sr))
|
29 |
+
t2 = time.time()
|
30 |
if _language_radio == 'cross' or _prompt_input_textbox == '':
|
31 |
output = model.inference_cross_lingual(_synthetic_input_textbox, prompt_speech_16k)
|
32 |
else:
|
33 |
output = model.inference_zero_shot(_synthetic_input_textbox, _prompt_input_textbox, prompt_speech_16k)
|
34 |
+
|
35 |
+
t3 = time.time()
|
36 |
audio_data = postprocess(output['tts_speech']).numpy().flatten()
|
37 |
+
t4 = time.time()
|
38 |
+
print(f'load and preprocess time: {t2-t1}s')
|
39 |
+
print(f'inference time: {t3-t2}s')
|
40 |
+
print(f'postprocess time: {t4-t3}s')
|
41 |
return (target_sr, audio_data)
|
42 |
|
43 |
with gr.Column():
|