Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -55,6 +55,7 @@ class Mandarin:
|
|
55 |
|
56 |
return wav, sample_rate
|
57 |
|
|
|
58 |
def greet(audio, text, voice=None):
|
59 |
print(f"Log print: audio name=[{audio.name}], text=[{text}]")
|
60 |
|
@@ -70,6 +71,17 @@ def greet(audio, text, voice=None):
|
|
70 |
|
71 |
return output_file, voice
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
def main():
|
74 |
demo = gr.Interface(
|
75 |
fn=greet,
|
@@ -94,9 +106,12 @@ def new_main():
|
|
94 |
with gr.Column(scale=1):
|
95 |
output_audio = gr.Audio(type="file", label="Output Audio")
|
96 |
|
97 |
-
_ = submit.click(
|
98 |
|
99 |
demo.launch()
|
100 |
|
101 |
if __name__=="__main__":
|
|
|
|
|
|
|
102 |
new_main()
|
|
|
55 |
|
56 |
return wav, sample_rate
|
57 |
|
58 |
+
|
59 |
def greet(audio, text, voice=None):
|
60 |
print(f"Log print: audio name=[{audio.name}], text=[{text}]")
|
61 |
|
|
|
71 |
|
72 |
return output_file, voice
|
73 |
|
74 |
+
def new_greet(audio, text):
|
75 |
+
print(f"Log print: audio name=[{audio.name}], text=[{text}]")
|
76 |
+
|
77 |
+
wav, sample_rate = voice.say(text)
|
78 |
+
|
79 |
+
output_file = "".join( random.sample(string.ascii_lowercase + string.digits, 11) ) + ".wav"
|
80 |
+
|
81 |
+
write(output_file, sample_rate, wav.astype(np.float32))
|
82 |
+
|
83 |
+
return output_file
|
84 |
+
|
85 |
def main():
|
86 |
demo = gr.Interface(
|
87 |
fn=greet,
|
|
|
106 |
with gr.Column(scale=1):
|
107 |
output_audio = gr.Audio(type="file", label="Output Audio")
|
108 |
|
109 |
+
_ = submit.click(new_greet, inputs=[input_audio, input_text, statas], outputs=[output_audio, statas])
|
110 |
|
111 |
demo.launch()
|
112 |
|
113 |
if __name__=="__main__":
|
114 |
+
voice = Mandarin()
|
115 |
+
voice.setVoice(audio.name)
|
116 |
+
voice.say("加载成功")
|
117 |
new_main()
|