Skip to content

Commit 26736f1

Browse files
committed
add list supported languages
1 parent 8c5eb4f commit 26736f1

File tree

10 files changed

+222
-2
lines changed

10 files changed

+222
-2
lines changed

plugins/local-stt/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ hypr-am = { workspace = true }
4444
hypr-audio-utils = { workspace = true }
4545
hypr-download-interface = { workspace = true }
4646
hypr-file = { workspace = true }
47+
hypr-language = { workspace = true, features = ["whisper"] }
4748
hypr-transcribe-moonshine = { workspace = true }
4849
hypr-transcribe-whisper-local = { workspace = true }
4950
hypr-whisper-local = { workspace = true }

plugins/local-stt/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const COMMANDS: &[&str] = &[
1010
"get_current_model",
1111
"set_current_model",
1212
"list_supported_models",
13+
"list_supported_languages",
1314
];
1415

1516
fn main() {

plugins/local-stt/js/bindings.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ async stopServer(serverType: ServerType | null) : Promise<boolean> {
3939
},
4040
async listSupportedModels() : Promise<SttModelInfo[]> {
4141
return await TAURI_INVOKE("plugin:local-stt|list_supported_models");
42+
},
43+
async listSupportedLanguages(model: SupportedSttModel) : Promise<Language[]> {
44+
return await TAURI_INVOKE("plugin:local-stt|list_supported_languages", { model });
4245
}
4346
}
4447

@@ -54,6 +57,7 @@ async listSupportedModels() : Promise<SttModelInfo[]> {
5457

5558
export type AmModel = "am-parakeet-v2" | "am-parakeet-v3" | "am-whisper-large-v3"
5659
export type GgmlBackend = { kind: string; name: string; description: string; total_memory_mb: number; free_memory_mb: number }
60+
export type Language = { iso639: string }
5761
export type ServerType = "internal" | "external"
5862
export type SttModelInfo = { key: SupportedSttModel; display_name: string; size_bytes: number }
5963
export type SupportedSttModel = WhisperModel | AmModel
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated - DO NOT EDIT!
2+
3+
"$schema" = "../../schemas/schema.json"
4+
5+
[[permission]]
6+
identifier = "allow-list-supported-languages"
7+
description = "Enables the list_supported_languages command without any pre-configured scope."
8+
commands.allow = ["list_supported_languages"]
9+
10+
[[permission]]
11+
identifier = "deny-list-supported-languages"
12+
description = "Denies the list_supported_languages command without any pre-configured scope."
13+
commands.deny = ["list_supported_languages"]

plugins/local-stt/permissions/autogenerated/reference.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Default permissions for the plugin
1414
- `allow-get-current-model`
1515
- `allow-set-current-model`
1616
- `allow-list-supported-models`
17+
- `allow-list-supported-languages`
1718

1819
## Permission Table
1920

@@ -287,6 +288,32 @@ Denies the list_pro_models command without any pre-configured scope.
287288
<tr>
288289
<td>
289290

291+
`local-stt:allow-list-supported-languages`
292+
293+
</td>
294+
<td>
295+
296+
Enables the list_supported_languages command without any pre-configured scope.
297+
298+
</td>
299+
</tr>
300+
301+
<tr>
302+
<td>
303+
304+
`local-stt:deny-list-supported-languages`
305+
306+
</td>
307+
<td>
308+
309+
Denies the list_supported_languages command without any pre-configured scope.
310+
311+
</td>
312+
</tr>
313+
314+
<tr>
315+
<td>
316+
290317
`local-stt:allow-list-supported-models`
291318

292319
</td>

plugins/local-stt/permissions/default.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ permissions = [
1111
"allow-get-current-model",
1212
"allow-set-current-model",
1313
"allow-list-supported-models",
14+
"allow-list-supported-languages",
1415
]

plugins/local-stt/permissions/schemas/schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,18 @@
414414
"const": "deny-list-pro-models",
415415
"markdownDescription": "Denies the list_pro_models command without any pre-configured scope."
416416
},
417+
{
418+
"description": "Enables the list_supported_languages command without any pre-configured scope.",
419+
"type": "string",
420+
"const": "allow-list-supported-languages",
421+
"markdownDescription": "Enables the list_supported_languages command without any pre-configured scope."
422+
},
423+
{
424+
"description": "Denies the list_supported_languages command without any pre-configured scope.",
425+
"type": "string",
426+
"const": "deny-list-supported-languages",
427+
"markdownDescription": "Denies the list_supported_languages command without any pre-configured scope."
428+
},
417429
{
418430
"description": "Enables the list_supported_models command without any pre-configured scope.",
419431
"type": "string",
@@ -499,10 +511,10 @@
499511
"markdownDescription": "Denies the stop_server command without any pre-configured scope."
500512
},
501513
{
502-
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-model-downloaded`\n- `allow-is-model-downloading`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-get-servers`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`",
514+
"description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-model-downloaded`\n- `allow-is-model-downloading`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-get-servers`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`\n- `allow-list-supported-languages`",
503515
"type": "string",
504516
"const": "default",
505-
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-model-downloaded`\n- `allow-is-model-downloading`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-get-servers`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`"
517+
"markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-models-dir`\n- `allow-is-model-downloaded`\n- `allow-is-model-downloading`\n- `allow-download-model`\n- `allow-start-server`\n- `allow-stop-server`\n- `allow-get-servers`\n- `allow-get-current-model`\n- `allow-set-current-model`\n- `allow-list-supported-models`\n- `allow-list-supported-languages`"
506518
}
507519
]
508520
}

plugins/local-stt/src/commands.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,9 @@ pub async fn get_servers<R: tauri::Runtime>(
103103
) -> Result<HashMap<ServerType, Option<String>>, String> {
104104
app.get_servers().await.map_err(|e| e.to_string())
105105
}
106+
107+
#[tauri::command]
108+
#[specta::specta]
109+
pub fn list_supported_languages(model: SupportedSttModel) -> Vec<hypr_language::Language> {
110+
model.supported_languages()
111+
}

plugins/local-stt/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn make_specta_builder<R: tauri::Runtime>() -> tauri_specta::Builder<R> {
4444
commands::start_server::<Wry>,
4545
commands::stop_server::<Wry>,
4646
commands::list_supported_models,
47+
commands::list_supported_languages,
4748
])
4849
.typ::<hypr_whisper_local_model::WhisperModel>()
4950
.error_handling(tauri_specta::ErrorHandlingMode::Throw)

plugins/local-stt/src/model.rs

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,160 @@ pub enum SupportedSttModel {
2929
}
3030

3131
impl SupportedSttModel {
32+
pub fn supported_languages(&self) -> Vec<hypr_language::Language> {
33+
use hypr_language::ISO639;
34+
35+
let whisper_multi_languages: Vec<hypr_language::Language> = vec![
36+
ISO639::Af.into(),
37+
ISO639::Am.into(),
38+
ISO639::Ar.into(),
39+
ISO639::As.into(),
40+
ISO639::Az.into(),
41+
ISO639::Ba.into(),
42+
ISO639::Be.into(),
43+
ISO639::Bg.into(),
44+
ISO639::Bn.into(),
45+
ISO639::Bo.into(),
46+
ISO639::Br.into(),
47+
ISO639::Bs.into(),
48+
ISO639::Ca.into(),
49+
ISO639::Cs.into(),
50+
ISO639::Cy.into(),
51+
ISO639::Da.into(),
52+
ISO639::De.into(),
53+
ISO639::El.into(),
54+
ISO639::En.into(),
55+
ISO639::Es.into(),
56+
ISO639::Et.into(),
57+
ISO639::Eu.into(),
58+
ISO639::Fa.into(),
59+
ISO639::Fi.into(),
60+
ISO639::Fo.into(),
61+
ISO639::Fr.into(),
62+
ISO639::Gl.into(),
63+
ISO639::Gu.into(),
64+
ISO639::Ha.into(),
65+
ISO639::He.into(),
66+
ISO639::Hi.into(),
67+
ISO639::Hr.into(),
68+
ISO639::Ht.into(),
69+
ISO639::Hu.into(),
70+
ISO639::Hy.into(),
71+
ISO639::Id.into(),
72+
ISO639::Is.into(),
73+
ISO639::It.into(),
74+
ISO639::Ja.into(),
75+
ISO639::Jv.into(),
76+
ISO639::Ka.into(),
77+
ISO639::Kk.into(),
78+
ISO639::Km.into(),
79+
ISO639::Kn.into(),
80+
ISO639::Ko.into(),
81+
ISO639::La.into(),
82+
ISO639::Lb.into(),
83+
ISO639::Lo.into(),
84+
ISO639::Lt.into(),
85+
ISO639::Lv.into(),
86+
ISO639::Mg.into(),
87+
ISO639::Mi.into(),
88+
ISO639::Mk.into(),
89+
ISO639::Ml.into(),
90+
ISO639::Mn.into(),
91+
ISO639::Mr.into(),
92+
ISO639::Ms.into(),
93+
ISO639::Mt.into(),
94+
ISO639::My.into(),
95+
ISO639::Ne.into(),
96+
ISO639::Nl.into(),
97+
ISO639::Nn.into(),
98+
ISO639::No.into(),
99+
ISO639::Oc.into(),
100+
ISO639::Pa.into(),
101+
ISO639::Pl.into(),
102+
ISO639::Ps.into(),
103+
ISO639::Pt.into(),
104+
ISO639::Ro.into(),
105+
ISO639::Ru.into(),
106+
ISO639::Sa.into(),
107+
ISO639::Sd.into(),
108+
ISO639::Si.into(),
109+
ISO639::Sk.into(),
110+
ISO639::Sl.into(),
111+
ISO639::Sn.into(),
112+
ISO639::So.into(),
113+
ISO639::Sq.into(),
114+
ISO639::Sr.into(),
115+
ISO639::Su.into(),
116+
ISO639::Sv.into(),
117+
ISO639::Sw.into(),
118+
ISO639::Ta.into(),
119+
ISO639::Te.into(),
120+
ISO639::Tg.into(),
121+
ISO639::Th.into(),
122+
ISO639::Tk.into(),
123+
ISO639::Tl.into(),
124+
ISO639::Tr.into(),
125+
ISO639::Tt.into(),
126+
ISO639::Uk.into(),
127+
ISO639::Ur.into(),
128+
ISO639::Uz.into(),
129+
ISO639::Vi.into(),
130+
ISO639::Yi.into(),
131+
ISO639::Yo.into(),
132+
ISO639::Zh.into(),
133+
];
134+
135+
// https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3
136+
let parakeet_v3_languages: Vec<hypr_language::Language> = vec![
137+
ISO639::Bg.into(),
138+
ISO639::Hr.into(),
139+
ISO639::Cs.into(),
140+
ISO639::Da.into(),
141+
ISO639::Nl.into(),
142+
ISO639::En.into(),
143+
ISO639::Et.into(),
144+
ISO639::Fi.into(),
145+
ISO639::Fr.into(),
146+
ISO639::De.into(),
147+
ISO639::El.into(),
148+
ISO639::Hu.into(),
149+
ISO639::It.into(),
150+
ISO639::Lv.into(),
151+
ISO639::Lt.into(),
152+
ISO639::Mt.into(),
153+
ISO639::Pl.into(),
154+
ISO639::Pt.into(),
155+
ISO639::Ro.into(),
156+
ISO639::Sk.into(),
157+
ISO639::Sl.into(),
158+
ISO639::Es.into(),
159+
ISO639::Sv.into(),
160+
ISO639::Ru.into(),
161+
ISO639::Uk.into(),
162+
];
163+
164+
match self {
165+
SupportedSttModel::Whisper(model) => match model {
166+
hypr_whisper_local_model::WhisperModel::QuantizedTinyEn
167+
| hypr_whisper_local_model::WhisperModel::QuantizedBaseEn
168+
| hypr_whisper_local_model::WhisperModel::QuantizedSmallEn => {
169+
vec![ISO639::En.into()]
170+
}
171+
hypr_whisper_local_model::WhisperModel::QuantizedTiny
172+
| hypr_whisper_local_model::WhisperModel::QuantizedBase
173+
| hypr_whisper_local_model::WhisperModel::QuantizedSmall
174+
| hypr_whisper_local_model::WhisperModel::QuantizedLargeTurbo => {
175+
whisper_multi_languages
176+
}
177+
},
178+
SupportedSttModel::Am(model) => match model {
179+
hypr_am::AmModel::ParakeetV2 => vec![ISO639::En.into()],
180+
hypr_am::AmModel::ParakeetV3 => parakeet_v3_languages,
181+
hypr_am::AmModel::WhisperLargeV3 => whisper_multi_languages,
182+
},
183+
}
184+
}
185+
32186
pub fn info(&self) -> SttModelInfo {
33187
match self {
34188
SupportedSttModel::Whisper(model) => SttModelInfo {

0 commit comments

Comments
 (0)