Spaces:
Running
on
Zero
Running
on
Zero
txya900619
commited on
Commit
•
ef63ede
1
Parent(s):
c410374
feat: add dapu babsuxuab raoping zhaoan to ipa.yaml
Browse files- app.py +11 -7
- configs/ipa.yaml +4 -0
- ipa/__init__.py +13 -7
app.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
4 |
-
import TTS
|
5 |
-
from TTS.utils.synthesizer import Synthesizer
|
6 |
import numpy as np
|
7 |
-
from huggingface_hub import snapshot_download
|
8 |
-
from omegaconf import OmegaConf
|
9 |
import spaces
|
10 |
import torch
|
|
|
|
|
|
|
|
|
11 |
|
12 |
from ipa.ipa import get_ipa, parse_ipa
|
13 |
from replace.tts import ChangedVitsConfig
|
@@ -45,8 +45,9 @@ OmegaConf.register_new_resolver("load_model", load_model)
|
|
45 |
|
46 |
models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
|
47 |
|
|
|
48 |
@spaces.GPU
|
49 |
-
def _do_tts(model_id, ipa, language_name,speaker_name=None, speaker_wav=None):
|
50 |
model = models_config[model_id]["model"]
|
51 |
if speaker_wav is not None:
|
52 |
return model.tts(
|
@@ -99,7 +100,10 @@ def text_to_speech(
|
|
99 |
return (
|
100 |
words,
|
101 |
pinyin,
|
102 |
-
(
|
|
|
|
|
|
|
103 |
)
|
104 |
|
105 |
|
@@ -131,7 +135,7 @@ def when_model_selected(model_id):
|
|
131 |
value=dialect_drop_down_choices[0][1],
|
132 |
interactive=len(dialect_drop_down_choices) > 1,
|
133 |
),
|
134 |
-
gr.update(visible=use_default_emb_or_ref_radio_visible, value="
|
135 |
)
|
136 |
|
137 |
|
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
|
|
|
|
4 |
import numpy as np
|
|
|
|
|
5 |
import spaces
|
6 |
import torch
|
7 |
+
import TTS
|
8 |
+
from huggingface_hub import snapshot_download
|
9 |
+
from omegaconf import OmegaConf
|
10 |
+
from TTS.utils.synthesizer import Synthesizer
|
11 |
|
12 |
from ipa.ipa import get_ipa, parse_ipa
|
13 |
from replace.tts import ChangedVitsConfig
|
|
|
45 |
|
46 |
models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
|
47 |
|
48 |
+
|
49 |
@spaces.GPU
|
50 |
+
def _do_tts(model_id, ipa, language_name, speaker_name=None, speaker_wav=None):
|
51 |
model = models_config[model_id]["model"]
|
52 |
if speaker_wav is not None:
|
53 |
return model.tts(
|
|
|
100 |
return (
|
101 |
words,
|
102 |
pinyin,
|
103 |
+
(
|
104 |
+
models_config[model_id]["model"].tts_model.config.audio.sample_rate,
|
105 |
+
np.array(wav),
|
106 |
+
),
|
107 |
)
|
108 |
|
109 |
|
|
|
135 |
value=dialect_drop_down_choices[0][1],
|
136 |
interactive=len(dialect_drop_down_choices) > 1,
|
137 |
),
|
138 |
+
gr.update(visible=use_default_emb_or_ref_radio_visible, value="預設語者"),
|
139 |
)
|
140 |
|
141 |
|
configs/ipa.yaml
CHANGED
@@ -7,3 +7,7 @@ pinyin_to_ipa_dict: ${gh_download:FormoSpeech/FormoLexicon, release/pinyin_to_ip
|
|
7 |
lexicon:
|
8 |
sixian: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_sixian_c.json, ${gh_token}}
|
9 |
hailu: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_hailu_c.json, ${gh_token}}
|
|
|
|
|
|
|
|
|
|
7 |
lexicon:
|
8 |
sixian: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_sixian_c.json, ${gh_token}}
|
9 |
hailu: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_hailu_c.json, ${gh_token}}
|
10 |
+
dapu: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_dapu_c.json, ${gh_token}}
|
11 |
+
nansixian: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_nansixian_c.json, ${gh_token}}
|
12 |
+
raoping: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_raoping_c.json, ${gh_token}}
|
13 |
+
zhaoan: ${gh_download:FormoSpeech/FormoLexicon, release/lexicon_htia_zhaoan_c.json, ${gh_token}}
|
ipa/__init__.py
CHANGED
@@ -1,24 +1,30 @@
|
|
1 |
-
import
|
2 |
|
|
|
3 |
from omegaconf import OmegaConf
|
4 |
|
|
|
5 |
def gh_download(repo, path, token):
|
6 |
paths = [path] if isinstance(path, str) else path
|
7 |
result = None
|
8 |
-
headers = {
|
|
|
|
|
|
|
9 |
for path in paths:
|
10 |
-
url = f"https://api.github.com/repos/{repo}/contents/{path}"
|
11 |
response = requests.get(url, headers=headers)
|
12 |
if response.status_code != 200:
|
13 |
raise Exception(f"Failed to download {path} from {repo}")
|
14 |
-
|
15 |
if result is None:
|
16 |
result = response.json()
|
17 |
elif isinstance(result, list):
|
18 |
result.extend(response.json())
|
19 |
elif isinstance(result, dict):
|
20 |
result.update(response.json())
|
21 |
-
|
22 |
return result
|
23 |
-
|
24 |
-
|
|
|
|
1 |
+
import time
|
2 |
|
3 |
+
import requests
|
4 |
from omegaconf import OmegaConf
|
5 |
|
6 |
+
|
7 |
def gh_download(repo, path, token):
|
8 |
paths = [path] if isinstance(path, str) else path
|
9 |
result = None
|
10 |
+
headers = {
|
11 |
+
"Authorization": f"Bearer {token}",
|
12 |
+
"Accept": "application/vnd.github.raw+json",
|
13 |
+
}
|
14 |
for path in paths:
|
15 |
+
url = f"https://api.github.com/repos/{repo}/contents/{path}"
|
16 |
response = requests.get(url, headers=headers)
|
17 |
if response.status_code != 200:
|
18 |
raise Exception(f"Failed to download {path} from {repo}")
|
19 |
+
|
20 |
if result is None:
|
21 |
result = response.json()
|
22 |
elif isinstance(result, list):
|
23 |
result.extend(response.json())
|
24 |
elif isinstance(result, dict):
|
25 |
result.update(response.json())
|
26 |
+
time.sleep(1)
|
27 |
return result
|
28 |
+
|
29 |
+
|
30 |
+
OmegaConf.register_new_resolver("gh_download", gh_download)
|