Spaces:
Running
Running
whisper : add whisper_lang_str_full (#1546)
Browse files* Update whisper.h
add whisper_lang_fullstr to retrieve the full language name
* Update whisper.cpp
add whisper_lang_fullstr to return the full language name
* fullstr -> str_full
---------
Co-authored-by: Georgi Gerganov <[email protected]>
- whisper.cpp +11 -0
- whisper.h +3 -0
whisper.cpp
CHANGED
|
@@ -3593,6 +3593,17 @@ const char * whisper_lang_str(int id) {
|
|
| 3593 |
return nullptr;
|
| 3594 |
}
|
| 3595 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3596 |
int whisper_lang_auto_detect_with_state(
|
| 3597 |
struct whisper_context * ctx,
|
| 3598 |
struct whisper_state * state,
|
|
|
|
| 3593 |
return nullptr;
|
| 3594 |
}
|
| 3595 |
|
| 3596 |
+
const char * whisper_lang_str_full(int id) {
|
| 3597 |
+
for (const auto & kv : g_lang) {
|
| 3598 |
+
if (kv.second.first == id) {
|
| 3599 |
+
return kv.second.second.c_str();
|
| 3600 |
+
}
|
| 3601 |
+
}
|
| 3602 |
+
|
| 3603 |
+
WHISPER_LOG_ERROR("%s: unknown language id %d\n", __func__, id);
|
| 3604 |
+
return nullptr;
|
| 3605 |
+
}
|
| 3606 |
+
|
| 3607 |
int whisper_lang_auto_detect_with_state(
|
| 3608 |
struct whisper_context * ctx,
|
| 3609 |
struct whisper_state * state,
|
whisper.h
CHANGED
|
@@ -315,6 +315,9 @@ extern "C" {
|
|
| 315 |
// Return the short string of the specified language id (e.g. 2 -> "de"), returns nullptr if not found
|
| 316 |
WHISPER_API const char * whisper_lang_str(int id);
|
| 317 |
|
|
|
|
|
|
|
|
|
|
| 318 |
// Use mel data at offset_ms to try and auto-detect the spoken language
|
| 319 |
// Make sure to call whisper_pcm_to_mel() or whisper_set_mel() first
|
| 320 |
// Returns the top language id or negative on failure
|
|
|
|
| 315 |
// Return the short string of the specified language id (e.g. 2 -> "de"), returns nullptr if not found
|
| 316 |
WHISPER_API const char * whisper_lang_str(int id);
|
| 317 |
|
| 318 |
+
// Return the short string of the specified language name (e.g. 2 -> "german"), returns nullptr if not found
|
| 319 |
+
WHISPER_API const char * whisper_lang_str_full(int id);
|
| 320 |
+
|
| 321 |
// Use mel data at offset_ms to try and auto-detect the spoken language
|
| 322 |
// Make sure to call whisper_pcm_to_mel() or whisper_set_mel() first
|
| 323 |
// Returns the top language id or negative on failure
|