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

Add function to get the final (auto-detected) language

Open sindresorhus opened this issue 1 year ago • 2 comments

When you set the language to auto-detect, whisper_full() sets params.languages to the detected language. The problem is that this is only available after whisper_full() has run, which is after the whole transcription. I would like to show the user the detected language right away. I'm planning to do this in the first new_segment_callback callback call. It would be useful to have a function whisper_get_language(context) that returns the language ID. I could then call this function inside new_segment_callback.

sindresorhus avatar Feb 25 '23 19:02 sindresorhus

Testing the wasm version within a browser Im able to see the language in the first place via console

whisper_full: auto-detected language: es (p = 0.897221)

DavidGOrtega avatar Mar 08 '23 12:03 DavidGOrtega

@sindresorhus This function was added recently (a1c1583cc7cd8b75222857afc936f0638c5683d6) but this issue wasn't tagged:

https://github.com/ggerganov/whisper.cpp/blob/09e90680072d8ecdf02eaf21c393218385d2c616/whisper.h#L422-L425

ggerganov avatar Mar 08 '23 17:03 ggerganov

@ggerganov Thanks for adding that 👍

sindresorhus avatar Mar 09 '23 02:03 sindresorhus