Skip to content

Conversation

eliranwong
Copy link

added method 'recognize_whispercpp' to support whisper.cpp as backend for recognizing speech

        Adapted from code: https://github.com/eliranwong/freegenius/blob/96d2fd7751ca26f2c7adaa63082a3cb79681f3ed/package/freegenius/utils/prompts.py#L118

        Performs speech recognition on ``audio_data`` (an ``AudioData`` instance), using Whisper.

        ``whispercpp_main`` is the local path of the main file of whisper.cpp, it depends on how users set up their local copies of whisper.cpp

        e.g., with the following setup, set '~/whisper.cpp/main' as ``whispercpp_main``:

        > cd ~

        > git clone https://github.com/ggerganov/whisper.cpp.git

        > cd whisper.cpp

        > make

        ``model_path`` is the local file path of any of *.bin files downloaded from https://huggingface.co/ggerganov/whisper.cpp/tree/main.

        e.g. download 'ggml-large-v3-q5_0.bin' to home directory, then ``model_path`` is '~/ggml-large-v3-q5_0.bin'

        The recognition language is determined by ``language``, an uncapitalized language code like "en" or "zh". 'auto' for auto-detect. See the full language list at https://github.com/openai/whisper/blob/main/whisper/tokenizer.py

        e.g. set 'en' as ``language`` for English

        e.g. set 'auto' as ``language`` for non-English languages

        ``additional_options`` are additional options that are passed directly to whisper.cpp. See https://github.com/ggerganov/whisper.cpp/tree/master/examples/main for all options

        e.g. set '-t 12' as ``additional_options``, to use 12 threads during computation

        e.g. set '-tr' as ``additional_options``, to translate from the speech to english

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant