Spaces:
Sleeping
Sleeping
SayaSS
commited on
Commit
•
d95ac39
1
Parent(s):
fa92db6
fix download button
Browse files
app.py
CHANGED
@@ -59,8 +59,8 @@ download_audio_js = """
|
|
59 |
let root = document.querySelector("body > gradio-app");
|
60 |
if (root.shadowRoot != null)
|
61 |
root = root.shadowRoot;
|
62 |
-
let audio = root.querySelector("#tts-audio").querySelector("audio");
|
63 |
-
let text = root.querySelector("#input-text").querySelector("textarea");
|
64 |
if (audio == undefined)
|
65 |
return;
|
66 |
text = text.value;
|
@@ -123,7 +123,7 @@ if __name__ == '__main__':
|
|
123 |
)
|
124 |
with gr.Row():
|
125 |
with gr.Column():
|
126 |
-
input_text = gr.Textbox(label="Text (100 words limitation)", lines=5, value="先生。今日も全力であなたをアシストしますね。", elem_id=f"input-text")
|
127 |
lang = gr.Dropdown(label="Language", choices=["Chinese", "Japanese", "Mix(wrap the Chinese text with [ZH][ZH], wrap the Japanese text with [JA][JA])"],
|
128 |
type="index", value="Japanese")
|
129 |
btn = gr.Button(value="Generate")
|
@@ -133,10 +133,10 @@ if __name__ == '__main__':
|
|
133 |
ls = gr.Slider(label="length_scale", minimum=0.1, maximum=2.0, step=0.1, value=1, interactive=True)
|
134 |
with gr.Column():
|
135 |
o1 = gr.Textbox(label="Output Message")
|
136 |
-
o2 = gr.Audio(label="Output Audio", elem_id=f"tts-audio")
|
137 |
download = gr.Button("Download Audio")
|
138 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls], outputs=[o1, o2])
|
139 |
-
download.click(None, [], [], _js=download_audio_js.format())
|
140 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
141 |
with gr.TabItem("中文"):
|
142 |
for (sid, name_en, name_zh, title, cover, net_g_ms, tts_fn) in models:
|
@@ -150,7 +150,7 @@ if __name__ == '__main__':
|
|
150 |
)
|
151 |
with gr.Row():
|
152 |
with gr.Column():
|
153 |
-
input_text = gr.Textbox(label="文本 (100字上限)", lines=5, value="先生。今日も全力であなたをアシストしますね。", elem_id=f"input-text")
|
154 |
lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
|
155 |
type="index", value="日语")
|
156 |
btn = gr.Button(value="生成")
|
@@ -160,9 +160,9 @@ if __name__ == '__main__':
|
|
160 |
ls = gr.Slider(label="控制整体语速", minimum=0.1, maximum=2.0, step=0.1, value=1, interactive=True)
|
161 |
with gr.Column():
|
162 |
o1 = gr.Textbox(label="输出信息")
|
163 |
-
o2 = gr.Audio(label="输出音频", elem_id=f"tts-audio")
|
164 |
download = gr.Button("下载音频")
|
165 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls], outputs=[o1, o2])
|
166 |
-
download.click(None, [], [], _js=download_audio_js.format())
|
167 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
168 |
app.queue(concurrency_count=1).launch(show_api=False, share=args.share)
|
|
|
59 |
let root = document.querySelector("body > gradio-app");
|
60 |
if (root.shadowRoot != null)
|
61 |
root = root.shadowRoot;
|
62 |
+
let audio = root.querySelector("#tts-audio-{audio_id}").querySelector("audio");
|
63 |
+
let text = root.querySelector("#input-text-{audio_id}").querySelector("textarea");
|
64 |
if (audio == undefined)
|
65 |
return;
|
66 |
text = text.value;
|
|
|
123 |
)
|
124 |
with gr.Row():
|
125 |
with gr.Column():
|
126 |
+
input_text = gr.Textbox(label="Text (100 words limitation)", lines=5, value="先生。今日も全力であなたをアシストしますね。", elem_id=f"input-text-en-{name_en.replace(' ','')}")
|
127 |
lang = gr.Dropdown(label="Language", choices=["Chinese", "Japanese", "Mix(wrap the Chinese text with [ZH][ZH], wrap the Japanese text with [JA][JA])"],
|
128 |
type="index", value="Japanese")
|
129 |
btn = gr.Button(value="Generate")
|
|
|
133 |
ls = gr.Slider(label="length_scale", minimum=0.1, maximum=2.0, step=0.1, value=1, interactive=True)
|
134 |
with gr.Column():
|
135 |
o1 = gr.Textbox(label="Output Message")
|
136 |
+
o2 = gr.Audio(label="Output Audio", elem_id=f"tts-audio-en-{name_en.replace(' ','')}")
|
137 |
download = gr.Button("Download Audio")
|
138 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls], outputs=[o1, o2])
|
139 |
+
download.click(None, [], [], _js=download_audio_js.format(audio_id=f"en-{name_en.replace(' ','')}"))
|
140 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
141 |
with gr.TabItem("中文"):
|
142 |
for (sid, name_en, name_zh, title, cover, net_g_ms, tts_fn) in models:
|
|
|
150 |
)
|
151 |
with gr.Row():
|
152 |
with gr.Column():
|
153 |
+
input_text = gr.Textbox(label="文本 (100字上限)", lines=5, value="先生。今日も全力であなたをアシストしますね。", elem_id=f"input-text-zh-{name_zh}")
|
154 |
lang = gr.Dropdown(label="语言", choices=["中文", "日语", "中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)"],
|
155 |
type="index", value="日语")
|
156 |
btn = gr.Button(value="生成")
|
|
|
160 |
ls = gr.Slider(label="控制整体语速", minimum=0.1, maximum=2.0, step=0.1, value=1, interactive=True)
|
161 |
with gr.Column():
|
162 |
o1 = gr.Textbox(label="输出信息")
|
163 |
+
o2 = gr.Audio(label="输出音频", elem_id=f"tts-audio-zh-{name_zh}")
|
164 |
download = gr.Button("下载音频")
|
165 |
btn.click(tts_fn, inputs=[input_text, lang, ns, nsw, ls], outputs=[o1, o2])
|
166 |
+
download.click(None, [], [], _js=download_audio_js.format(audio_id=f"zh-{name_zh}"))
|
167 |
lang.change(change_lang, inputs=[lang], outputs=[ns, nsw, ls])
|
168 |
app.queue(concurrency_count=1).launch(show_api=False, share=args.share)
|