Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,8 +2,6 @@
|
|
2 |
#
|
3 |
# Copyright 2022-2023 Xiaomi Corp. (authors: Fangjun Kuang)
|
4 |
#
|
5 |
-
# See LICENSE for clarification regarding multiple authors
|
6 |
-
#
|
7 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
8 |
# you may not use this file except in compliance with the License.
|
9 |
# You may obtain a copy of the License at
|
@@ -16,9 +14,6 @@
|
|
16 |
# See the License for the specific language governing permissions and
|
17 |
# limitations under the License.
|
18 |
|
19 |
-
# References:
|
20 |
-
# https://gradio.app/docs/#dropdown
|
21 |
-
|
22 |
import logging
|
23 |
import os
|
24 |
import time
|
@@ -33,29 +28,19 @@ title = "# Next-gen Kaldi: Text-to-speech (TTS)"
|
|
33 |
|
34 |
description = """
|
35 |
This space shows how to convert text to speech with Next-gen Kaldi.
|
36 |
-
|
37 |
It is running on CPU within a docker container provided by Hugging Face.
|
38 |
-
|
39 |
See more information by visiting the following links:
|
40 |
-
|
41 |
- <https://github.com/k2-fsa/sherpa-onnx>
|
42 |
-
|
43 |
If you want to deploy it locally, please see
|
44 |
<https://k2-fsa.github.io/sherpa/>
|
45 |
-
|
46 |
If you want to use Android APKs, please see
|
47 |
<https://k2-fsa.github.io/sherpa/onnx/tts/apk.html>
|
48 |
-
|
49 |
If you want to use Android text-to-speech engine APKs, please see
|
50 |
<https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html>
|
51 |
-
|
52 |
If you want to download an all-in-one exe for Windows, please see
|
53 |
<https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models>
|
54 |
-
|
55 |
"""
|
56 |
|
57 |
-
# css style is copied from
|
58 |
-
# https://huggingface.co/spaces/alphacep/asr/blob/main/app.py#L113
|
59 |
css = """
|
60 |
.result {display:flex;flex-direction:column}
|
61 |
.result_item {padding:15px;margin-bottom:8px;border-radius:15px;width:100%}
|
@@ -93,7 +78,7 @@ examples = [
|
|
93 |
def update_model_dropdown(language: str):
|
94 |
if language in language_to_models:
|
95 |
choices = language_to_models[language]
|
96 |
-
return gr.Dropdown(
|
97 |
choices=choices,
|
98 |
value=choices[0],
|
99 |
interactive=True,
|
@@ -154,7 +139,6 @@ def process(language: str, repo_id: str, text: str, sid: str, speed: float):
|
|
154 |
|
155 |
demo = gr.Blocks(css=css)
|
156 |
|
157 |
-
|
158 |
with demo:
|
159 |
gr.Markdown(title)
|
160 |
language_choices = list(language_to_models.keys())
|
@@ -258,5 +242,4 @@ if __name__ == "__main__":
|
|
258 |
formatter = "%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s"
|
259 |
|
260 |
logging.basicConfig(format=formatter, level=logging.INFO)
|
261 |
-
|
262 |
demo.launch()
|
|
|
2 |
#
|
3 |
# Copyright 2022-2023 Xiaomi Corp. (authors: Fangjun Kuang)
|
4 |
#
|
|
|
|
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
6 |
# you may not use this file except in compliance with the License.
|
7 |
# You may obtain a copy of the License at
|
|
|
14 |
# See the License for the specific language governing permissions and
|
15 |
# limitations under the License.
|
16 |
|
|
|
|
|
|
|
17 |
import logging
|
18 |
import os
|
19 |
import time
|
|
|
28 |
|
29 |
description = """
|
30 |
This space shows how to convert text to speech with Next-gen Kaldi.
|
|
|
31 |
It is running on CPU within a docker container provided by Hugging Face.
|
|
|
32 |
See more information by visiting the following links:
|
|
|
33 |
- <https://github.com/k2-fsa/sherpa-onnx>
|
|
|
34 |
If you want to deploy it locally, please see
|
35 |
<https://k2-fsa.github.io/sherpa/>
|
|
|
36 |
If you want to use Android APKs, please see
|
37 |
<https://k2-fsa.github.io/sherpa/onnx/tts/apk.html>
|
|
|
38 |
If you want to use Android text-to-speech engine APKs, please see
|
39 |
<https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html>
|
|
|
40 |
If you want to download an all-in-one exe for Windows, please see
|
41 |
<https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models>
|
|
|
42 |
"""
|
43 |
|
|
|
|
|
44 |
css = """
|
45 |
.result {display:flex;flex-direction:column}
|
46 |
.result_item {padding:15px;margin-bottom:8px;border-radius:15px;width:100%}
|
|
|
78 |
def update_model_dropdown(language: str):
|
79 |
if language in language_to_models:
|
80 |
choices = language_to_models[language]
|
81 |
+
return gr.Dropdown.update(
|
82 |
choices=choices,
|
83 |
value=choices[0],
|
84 |
interactive=True,
|
|
|
139 |
|
140 |
demo = gr.Blocks(css=css)
|
141 |
|
|
|
142 |
with demo:
|
143 |
gr.Markdown(title)
|
144 |
language_choices = list(language_to_models.keys())
|
|
|
242 |
formatter = "%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s"
|
243 |
|
244 |
logging.basicConfig(format=formatter, level=logging.INFO)
|
|
|
245 |
demo.launch()
|