Spaces:
Build error
Build error
Commit
•
54ce256
0
Parent(s):
Duplicate from balacoon/tts
Browse filesCo-authored-by: Clement Ruhm <[email protected]>
- .gitattributes +31 -0
- .gitignore +1 -0
- README.md +13 -0
- app.py +103 -0
- requirements.txt +5 -0
- setup.cfg +12 -0
.gitattributes
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.idea
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Text-to-Speech
|
3 |
+
emoji: 💬
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.4
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: balacoon/tts
|
11 |
+
---
|
12 |
+
|
13 |
+
Text-to-Speech interactive demo, using (balacoon_tts)[https://balacoon.com].
|
app.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Copyright 2022 Balacoon
|
3 |
+
|
4 |
+
TTS interactive demo
|
5 |
+
"""
|
6 |
+
|
7 |
+
import logging
|
8 |
+
from typing import cast
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
from balacoon_tts import TTS
|
12 |
+
from huggingface_hub import hf_hub_download, list_repo_files
|
13 |
+
|
14 |
+
# global tts module, initialized from a model selected
|
15 |
+
tts = None
|
16 |
+
|
17 |
+
|
18 |
+
def main():
|
19 |
+
logging.basicConfig(level=logging.INFO)
|
20 |
+
|
21 |
+
with gr.Blocks() as demo:
|
22 |
+
gr.Markdown(
|
23 |
+
"""
|
24 |
+
<h1 align="center">Balacoon🦝 Text-to-Speech</h1>
|
25 |
+
|
26 |
+
1. Write an utterance to generate,
|
27 |
+
2. Select the model to synthesize with
|
28 |
+
3. Select speaker (only for multi-speaker models)
|
29 |
+
4. Hit "Generate" and listen to the result!
|
30 |
+
|
31 |
+
When you select model for the first time,
|
32 |
+
it will take a little time to download it.
|
33 |
+
You can learn more about models available
|
34 |
+
[here](https://huggingface.co/balacoon/tts),
|
35 |
+
visit [Balacoon website](https://balacoon.com/) for more info.
|
36 |
+
"""
|
37 |
+
)
|
38 |
+
with gr.Row(variant="panel"):
|
39 |
+
text = gr.Textbox(label="Text", placeholder="Type something here...")
|
40 |
+
|
41 |
+
with gr.Row():
|
42 |
+
with gr.Column(variant="panel"):
|
43 |
+
repo_files = list_repo_files(repo_id="balacoon/tts")
|
44 |
+
model_files = [x for x in repo_files if x.endswith(".addon")]
|
45 |
+
model_name = gr.Dropdown(
|
46 |
+
label="Model",
|
47 |
+
choices=model_files,
|
48 |
+
)
|
49 |
+
with gr.Column(variant="panel"):
|
50 |
+
speaker = gr.Dropdown(label="Speaker", choices=[])
|
51 |
+
|
52 |
+
def set_model(model_name_str: str):
|
53 |
+
"""
|
54 |
+
gets value from `model_name`, loads model,
|
55 |
+
re-initializes tts object, gets list of
|
56 |
+
speakers that model supports and set them to `speaker`
|
57 |
+
"""
|
58 |
+
model_path = hf_hub_download(
|
59 |
+
repo_id="balacoon/tts", filename=model_name_str
|
60 |
+
)
|
61 |
+
global tts
|
62 |
+
tts = TTS(model_path)
|
63 |
+
speakers = tts.get_speakers()
|
64 |
+
if speakers:
|
65 |
+
visible = True
|
66 |
+
value = speakers[-1]
|
67 |
+
else:
|
68 |
+
visible = False
|
69 |
+
value = ""
|
70 |
+
return gr.Dropdown.update(
|
71 |
+
choices=speakers, value=value, visible=visible
|
72 |
+
)
|
73 |
+
|
74 |
+
model_name.change(set_model, inputs=model_name, outputs=speaker)
|
75 |
+
|
76 |
+
with gr.Row(variant="panel"):
|
77 |
+
generate = gr.Button("Generate")
|
78 |
+
with gr.Row(variant="panel"):
|
79 |
+
audio = gr.Audio()
|
80 |
+
|
81 |
+
def synthesize_audio(text_str: str, speaker_str: str = ""):
|
82 |
+
"""
|
83 |
+
gets utterance to synthesize from `text` Textbox
|
84 |
+
and speaker name from `speaker` dropdown list.
|
85 |
+
speaker name might be empty for single-speaker models.
|
86 |
+
Synthesizes the waveform and updates `audio` with it.
|
87 |
+
"""
|
88 |
+
if not text_str:
|
89 |
+
logging.info("text or speaker are not provided")
|
90 |
+
return None
|
91 |
+
global tts
|
92 |
+
if len(text_str) > 1024:
|
93 |
+
text_str = text_str[:1024]
|
94 |
+
samples = cast(TTS, tts).synthesize(text_str, speaker_str)
|
95 |
+
return gr.Audio.update(value=(24000, samples))
|
96 |
+
|
97 |
+
generate.click(synthesize_audio, inputs=[text, speaker], outputs=audio)
|
98 |
+
|
99 |
+
demo.launch()
|
100 |
+
|
101 |
+
|
102 |
+
if __name__ == "__main__":
|
103 |
+
main()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--index-url https://pypi.fury.io/balacoon/
|
2 |
+
--extra-index-url https://pypi.org/simple/
|
3 |
+
balacoon-tts==0.0.2
|
4 |
+
huggingface_hub
|
5 |
+
numpy
|
setup.cfg
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[flake8]
|
2 |
+
max_complexity=10
|
3 |
+
per-file-ignores=__init__.py:F401,F403
|
4 |
+
ignore = E203,W503
|
5 |
+
max-line-length=119
|
6 |
+
|
7 |
+
[isort]
|
8 |
+
profile=black
|
9 |
+
line_length=119
|
10 |
+
|
11 |
+
[mypy]
|
12 |
+
ignore_missing_imports = True
|