Spaces:
Sleeping
Sleeping
txya900619
commited on
Commit
•
9577ea0
1
Parent(s):
09c0ada
feat: add merge model
Browse files- app.py +11 -3
- configs/models.yaml +4 -1
app.py
CHANGED
@@ -14,7 +14,11 @@ OmegaConf.register_new_resolver("load_vosk", load_vosk)
|
|
14 |
models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
|
15 |
|
16 |
def automatic_speech_recognition(model_id: str, dialect_id: str, audio_data: str):
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
sample_rate, audio_array = audio_data
|
19 |
if audio_array.ndim == 2:
|
20 |
audio_array = audio_array[:, 0]
|
@@ -51,6 +55,9 @@ def automatic_speech_recognition(model_id: str, dialect_id: str, audio_data: str
|
|
51 |
def when_model_selected(model_id: str):
|
52 |
model_config = models_config[model_id]
|
53 |
|
|
|
|
|
|
|
54 |
dialect_drop_down_choices = [
|
55 |
(k, v) for k, v in model_config["dialect_mapping"].items()
|
56 |
]
|
@@ -58,6 +65,7 @@ def when_model_selected(model_id: str):
|
|
58 |
return gr.update(
|
59 |
choices=dialect_drop_down_choices,
|
60 |
value=dialect_drop_down_choices[0][1],
|
|
|
61 |
)
|
62 |
|
63 |
|
@@ -103,8 +111,8 @@ with demo:
|
|
103 |
# 臺灣客語語音辨識系統
|
104 |
### Taiwanese Hakka Automatic-Speech-Recognition System
|
105 |
### 研發
|
106 |
-
- **[李鴻欣 Hung-Shin Lee](mailto:hungshinlee@gmail.com)
|
107 |
-
- **[陳力瑋 Li-Wei Chen](mailto:wayne900619@gmail.com)
|
108 |
"""
|
109 |
)
|
110 |
gr.Interface(
|
|
|
14 |
models_config = OmegaConf.to_object(OmegaConf.load("configs/models.yaml"))
|
15 |
|
16 |
def automatic_speech_recognition(model_id: str, dialect_id: str, audio_data: str):
|
17 |
+
if isinstance(models_config[model_id]["model"], dict):
|
18 |
+
model = models_config[model_id]["model"][dialect_id]
|
19 |
+
else:
|
20 |
+
model = models_config[model_id]["model"]
|
21 |
+
|
22 |
sample_rate, audio_array = audio_data
|
23 |
if audio_array.ndim == 2:
|
24 |
audio_array = audio_array[:, 0]
|
|
|
55 |
def when_model_selected(model_id: str):
|
56 |
model_config = models_config[model_id]
|
57 |
|
58 |
+
if "dialect_mapping" not in model_config["dialect_mapping"]:
|
59 |
+
return gr.update(visible=False)
|
60 |
+
|
61 |
dialect_drop_down_choices = [
|
62 |
(k, v) for k, v in model_config["dialect_mapping"].items()
|
63 |
]
|
|
|
65 |
return gr.update(
|
66 |
choices=dialect_drop_down_choices,
|
67 |
value=dialect_drop_down_choices[0][1],
|
68 |
+
visible=True,
|
69 |
)
|
70 |
|
71 |
|
|
|
111 |
# 臺灣客語語音辨識系統
|
112 |
### Taiwanese Hakka Automatic-Speech-Recognition System
|
113 |
### 研發
|
114 |
+
- **[李鴻欣 Hung-Shin Lee](mailto:hungshinlee@gmail.com)([聯和科創](https://www.104.com.tw/company/1a2x6bmu75))**
|
115 |
+
- **[陳力瑋 Li-Wei Chen](mailto:wayne900619@gmail.com)([聯和科創](https://www.104.com.tw/company/1a2x6bmu75))**
|
116 |
"""
|
117 |
)
|
118 |
gr.Interface(
|
configs/models.yaml
CHANGED
@@ -12,4 +12,7 @@ htia-0.1:
|
|
12 |
大埔: htia_dapu
|
13 |
饒平: htia_raoping
|
14 |
詔安: htia_zhaoan
|
15 |
-
南四縣: htia_nansixian
|
|
|
|
|
|
|
|
12 |
大埔: htia_dapu
|
13 |
饒平: htia_raoping
|
14 |
詔安: htia_zhaoan
|
15 |
+
南四縣: htia_nansixian
|
16 |
+
|
17 |
+
htia-0.1m:
|
18 |
+
model: ${load_vosk:formospeech/kaldi-taiwanese-hakka-merge}
|