Spaces:
Runtime error
Runtime error
yesyesjaewook
commited on
Commit
β’
00c7109
1
Parent(s):
195fa7e
Update TTS
Browse files- README.md +2 -1
- app.py +103 -27
- packages.txt +0 -0
- requirements.txt +4 -3
README.md
CHANGED
@@ -4,7 +4,8 @@ emoji: π©
|
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
-
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: wtfpl
|
|
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
sdk: gradio
|
7 |
+
python_version: 3.9
|
8 |
+
sdk_version: 3.24.1
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
license: wtfpl
|
app.py
CHANGED
@@ -7,23 +7,97 @@ import numpy as np
|
|
7 |
import torch
|
8 |
from espnet2.bin.tts_inference import Text2Speech
|
9 |
|
10 |
-
|
11 |
-
"jaewook": Text2Speech.from_pretrained("yesyesjaewook/jets-jaewook-ko"),
|
12 |
-
"jaewook_ukten": Text2Speech.from_pretrained("yesyesjaewook/jets-jaewook-ukten-ko"),
|
13 |
-
}
|
14 |
|
15 |
emotions = {
|
16 |
-
"
|
17 |
-
"
|
18 |
-
"
|
19 |
-
"
|
20 |
-
"
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
"
|
25 |
-
"
|
26 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
|
@@ -37,33 +111,35 @@ def endswith_punctuation(text: str) -> bool:
|
|
37 |
return re.search(r"[.?!]", text) is not None
|
38 |
|
39 |
|
40 |
-
def synthesize(text: str,
|
41 |
text = text.strip()
|
42 |
if not endswith_punctuation(text):
|
43 |
text += "."
|
44 |
|
45 |
-
print(f"[{datetime.now().isoformat()}] <{
|
46 |
|
47 |
-
model,
|
48 |
-
|
49 |
-
return (models[model].fs, float32_to_pcm16(output["wav"]))
|
50 |
|
51 |
|
52 |
with gr.Blocks() as demo:
|
53 |
-
gr.Markdown("# μ‘μ¬μ±
|
54 |
|
55 |
with gr.Row():
|
56 |
with gr.Column():
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
60 |
synthesize_button = gr.Button("ν©μ±")
|
61 |
-
|
62 |
-
with gr.Column():
|
63 |
with gr.Box():
|
64 |
ouptut = gr.Audio()
|
65 |
gr.Markdown("μμ± λ€μ΄λ‘λλ νλ μ΄μ΄ μ€λ₯Έμͺ½μ Β·Β·Β· λ©λ΄ ν΄λ¦ λΆνλ립λλ€ π")
|
66 |
|
67 |
-
|
|
|
|
|
|
|
68 |
|
69 |
demo.launch()
|
|
|
7 |
import torch
|
8 |
from espnet2.bin.tts_inference import Text2Speech
|
9 |
|
10 |
+
model = Text2Speech.from_pretrained("yesyesjaewook/jets-jaewook-ko")
|
|
|
|
|
|
|
11 |
|
12 |
emotions = {
|
13 |
+
"κ°μΎλ€": 1,
|
14 |
+
"κ°κ°νλ€": 2,
|
15 |
+
"κ°μμ€λ½λ€": 3,
|
16 |
+
"κ²½λ©Έμ€λ½λ€": 4,
|
17 |
+
"κ³ λ§λ€": 5,
|
18 |
+
"κ³ ν΅μ€λ½λ€": 6,
|
19 |
+
"κ³€λνλ€": 7,
|
20 |
+
"κ΄΄λ‘λ€": 8,
|
21 |
+
"κ΅μ₯νλ€": 9,
|
22 |
+
"그립λ€": 10,
|
23 |
+
"κΈνλ€": 11,
|
24 |
+
"κΈ°λ§νλ€": 12,
|
25 |
+
"κΈ΄λ°νλ€": 13,
|
26 |
+
"κΊΌλ¦ΌμΉνλ€": 14,
|
27 |
+
"λμ°νλ€": 15,
|
28 |
+
"λλ°μλ€": 16,
|
29 |
+
"λ¨μ¬μ€λ½λ€": 17,
|
30 |
+
"λμ νλ€": 18,
|
31 |
+
"λ
Ήλ
Ήνλ€": 19,
|
32 |
+
"λ€κΈνλ€": 20,
|
33 |
+
"λ΄λ°±νλ€": 21,
|
34 |
+
"λλμμ΄νλ€": 22,
|
35 |
+
"λλ ΅λ€": 23,
|
36 |
+
"λ₯κ·Έμ€λ¦νλ€": 24,
|
37 |
+
"λλ ·νλ€": 25,
|
38 |
+
"λ§μ‘±μ€λ½λ€": 26,
|
39 |
+
"λ§νλ€": 27,
|
40 |
+
"맀μ νλ€": 28,
|
41 |
+
"λͺ»λλ€": 29,
|
42 |
+
"무κ΄μ¬νλ€": 30,
|
43 |
+
"무λ‘νλ€": 31,
|
44 |
+
"λν΄νλ€": 32,
|
45 |
+
"λ°λ€": 33,
|
46 |
+
"λ°κ°λ€": 34,
|
47 |
+
"λ°°μλ§λνλ€": 35,
|
48 |
+
"λ²κ²λ€": 36,
|
49 |
+
"보μκ²μλ€": 37,
|
50 |
+
"λΆλλ½λ€": 38,
|
51 |
+
"λΆλΉνλ€": 39,
|
52 |
+
"λΆμ νλ€": 40,
|
53 |
+
"λΆμνλ€": 41,
|
54 |
+
"λΆννλ€": 42,
|
55 |
+
"λΆνμ€νλ€": 43,
|
56 |
+
"λ»λ»μ€λ½λ€": 44,
|
57 |
+
"λΌμνλ€": 45,
|
58 |
+
"μ¬λμ€λ½λ€": 46,
|
59 |
+
"μλ½λ€": 47,
|
60 |
+
"μμνλ€": 48,
|
61 |
+
"μμνλ€": 49,
|
62 |
+
"μ¬νλ€": 50,
|
63 |
+
"μ무룩νλ€": 51,
|
64 |
+
"μ¬λνλ€": 52,
|
65 |
+
"μ°λ¦¬λ€": 53,
|
66 |
+
"μΈμΈνλ€": 54,
|
67 |
+
"μλκΌ½λ€": 55,
|
68 |
+
"μλνλ€": 56,
|
69 |
+
"μμ½λ€": 57,
|
70 |
+
"μμ°νλ€": 58,
|
71 |
+
"μ
λνλ€": 59,
|
72 |
+
"μνκΉλ€": 60,
|
73 |
+
"μ½νλ€": 61,
|
74 |
+
"μλ€": 62,
|
75 |
+
"μ΄λ ΄ννλ€": 63,
|
76 |
+
"μ΄λ¦¬λ₯μ νλ€": 64,
|
77 |
+
"μ΅μΈνλ€": 65,
|
78 |
+
"μΈμ§’λ€": 66,
|
79 |
+
"μλ°νλ€": 67,
|
80 |
+
"μμ€νλ€": 68,
|
81 |
+
"μλ±νλ€": 69,
|
82 |
+
"μκ΄μ€λ½λ€": 70,
|
83 |
+
"μμ¬λ‘λ€": 71,
|
84 |
+
"μΈλ‘λ€": 72,
|
85 |
+
"μννλ€": 73,
|
86 |
+
"μμ¬μ€λ½λ€": 74,
|
87 |
+
"μλμ€λ½λ€": 75,
|
88 |
+
"μμΈνλ€": 76,
|
89 |
+
"μμ λ‘λ€": 77,
|
90 |
+
"μ‘°λ§μ‘°λ§νλ€": 78,
|
91 |
+
"μ¦κ²λ€": 79,
|
92 |
+
"μ§μ¦μ€λ½λ€": 80,
|
93 |
+
"μ°½νΌνλ€": 81,
|
94 |
+
"μΉμμ€λ½λ€": 82,
|
95 |
+
"νμ¬νλ€": 83,
|
96 |
+
"ν볡νλ€": 84,
|
97 |
+
"νΌλνλ€": 85,
|
98 |
+
"νκ°λΆνλ€": 86,
|
99 |
+
"νλͺ©νλ€": 87,
|
100 |
+
"νλνλ€": 88,
|
101 |
}
|
102 |
|
103 |
|
|
|
111 |
return re.search(r"[.?!]", text) is not None
|
112 |
|
113 |
|
114 |
+
def synthesize(text: str, emotion: str) -> Tuple[int, np.array]:
|
115 |
text = text.strip()
|
116 |
if not endswith_punctuation(text):
|
117 |
text += "."
|
118 |
|
119 |
+
print(f"[{datetime.now().isoformat()}] <{emotion}> {text}")
|
120 |
|
121 |
+
output = model(text, lids=np.array(emotions[emotion]))
|
122 |
+
return (model.fs, float32_to_pcm16(output["wav"]))
|
|
|
123 |
|
124 |
|
125 |
with gr.Blocks() as demo:
|
126 |
+
gr.Markdown("# μ‘μ¬μ± TTS νλ‘μ νΈ")
|
127 |
|
128 |
with gr.Row():
|
129 |
with gr.Column():
|
130 |
+
text = gr.Textbox(
|
131 |
+
label="ν
μ€νΈ",
|
132 |
+
value="κ·Έλμ μ¬λν΄μ£Όμ λΆλ€μκ²λ κ°μ¬νλ€λ λ§λ§ μ νκ³ μΆμ΅λλ€. μ λ°©μ‘ νμλ‘ 3λ
μ΄ νλ₯΄κ³ μ§κΈ μ¬κΈ°κΉμ§ μ€λλ° κ΅μ₯ν λ
Έλ ₯λ§μ΄νμ΅λλ€.",
|
133 |
+
lines=3,
|
134 |
+
)
|
135 |
synthesize_button = gr.Button("ν©μ±")
|
|
|
|
|
136 |
with gr.Box():
|
137 |
ouptut = gr.Audio()
|
138 |
gr.Markdown("μμ± λ€μ΄λ‘λλ νλ μ΄μ΄ μ€λ₯Έμͺ½μ Β·Β·Β· λ©λ΄ ν΄λ¦ λΆνλ립λλ€ π")
|
139 |
|
140 |
+
with gr.Column():
|
141 |
+
emotion = gr.Radio(label="κ°μ ", choices=[*emotions.keys()], value="λ΄λ°±νλ€")
|
142 |
+
|
143 |
+
synthesize_button.click(fn=synthesize, inputs=[text, emotion], outputs=ouptut)
|
144 |
|
145 |
demo.launch()
|
packages.txt
DELETED
File without changes
|
requirements.txt
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
-
|
2 |
g2pk
|
3 |
-
git+https://github.com/espnet/espnet
|
4 |
numpy
|
5 |
-
rich
|
|
|
|
|
|
1 |
+
espnet-model-zoo==0.1.7
|
2 |
g2pk
|
|
|
3 |
numpy
|
4 |
+
rich
|
5 |
+
torch~=1.13.0
|
6 |
+
typeguard==2.13.3
|