whisper.cpp icon indicating copy to clipboard operation
whisper.cpp copied to clipboard

return language code with transcription

Open qxprakash opened this issue 11 months ago • 2 comments

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.

qxprakash avatar Mar 26 '24 20:03 qxprakash

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?

bradmit avatar Apr 03 '24 23:04 bradmit

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 !!

qxprakash avatar Apr 07 '24 07:04 qxprakash