whisper.cpp
whisper.cpp copied to clipboard
return language code with transcription
when running a non .en model , and running with flag -l auto , it transcribes the audio into different languages , It would have been nice if it would have detected the langauge of the audio and return it in response along with transcription.
There is the print segment callback which has the information you're referring to in it. In the application I've integrated whisper cpp into.....
void whisper_print_segment_callback(struct whisper_context* ctx, struct whisper_state* state, int n_new, void* user_data) ... int langId = whisper_full_lang_id_from_state(state); ... You can then get the lang code and language full name: whisper_lang_str(langId) whisper_lang_str_full(langId)
Or am I missing something?
Hi @bradmit sorry I missed one important detail here , I wanted the language code along with the transcrption , in the whisper.cpp server , currently the output of the server is something like this {'text': 'transcription of the audio file'} , I haved something like , {'text': 'transcription of the audio file' , detected_lang: "en"} is something like this possible ? , if yes which parts of the codebase should I modify to achieve this ? , Thanks !!