From a6e3105fd77a7de2bab3441cb1f74f70695e942a Mon Sep 17 00:00:00 2001 From: killian <63927363+KillianLucas@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:54:03 -0800 Subject: [PATCH] Revert "fix: download whisper local model directly from huggingface" --- OS/01/start.sh | 13 +++---------- OS/01/stt.py | 11 +++++------ README.md | 3 ++- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/OS/01/start.sh b/OS/01/start.sh index 18187bf..8107a17 100755 --- a/OS/01/start.sh +++ b/OS/01/start.sh @@ -1,12 +1,10 @@ ### SETTINGS # If ALL_LOCAL is False, we'll use OpenAI's services -# else we use whisper.cpp and piper local models +# If setting ALL_LOCAL to true, set the path to the WHISPER local model export ALL_LOCAL=False -export WHISPER_MODEL_NAME="ggml-tiny.en.bin" - -# Uncomment and set the OpenAI API key for OpenInterpreter to work -# export OPENAI_API_KEY="sk-..." +# export WHISPER_MODEL_PATH=... +export OPENAI_API_KEY="sk-..." # Expose through Ngrok # Uncomment following line with your Ngrok auth token (https://dashboard.ngrok.com/get-started/your-authtoken) @@ -40,11 +38,6 @@ export LOG_LEVEL="INFO" ### SETUP # if using local models, install the models / executables -WHISPER_MODEL_URL="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/" -WHISPER_RUST_PATH="`pwd`/local_stt/whisper-rust" - -curl -OL "${WHISPER_MODEL_URL}${WHISPER_MODEL_NAME}" --output-dir ${WHISPER_RUST_PATH} - if [[ "$ALL_LOCAL" == "True" ]]; then OS=$(uname -s) ARCH=$(uname -m) diff --git a/OS/01/stt.py b/OS/01/stt.py index 48f0ed6..aa14e24 100644 --- a/OS/01/stt.py +++ b/OS/01/stt.py @@ -53,14 +53,13 @@ def run_command(command): return result.stdout, result.stderr def get_transcription_file(wav_file_path: str): - whisper_rust_path = os.path.join(os.path.dirname(__file__), 'local_stt', 'whisper-rust') - model_name = os.getenv('WHISPER_MODEL_NAME') - if not model_name: - raise EnvironmentError("WHISPER_MODEL_NAME environment variable is not set.") + model_path = os.getenv("WHISPER_MODEL_PATH") + if not model_path: + raise EnvironmentError("WHISPER_MODEL_PATH environment variable is not set.") output, error = run_command([ - os.path.join(whisper_rust_path, 'whisper-rust'), - '--model-path', os.path.join(whisper_rust_path, model_name), + os.path.join(os.path.dirname(__file__), 'local_stt', 'whisper-rust', 'whisper-rust'), + '--model-path', model_path, '--file-path', wav_file_path ]) diff --git a/README.md b/README.md index f092ce9..5350605 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ python -m pip install -r requirements.txt ``` NB: Depending on your local Python version, you may run into [this issue↗](https://github.com/TaylorSMarks/playsound/issues/150) installing playsound. Workarounds are provided in the issue. +If you want to run local speech-to-text from whisper, download the GGML Whisper model from [Huggingface](https://huggingface.co/ggerganov/whisper.cpp). Then in `OS/01/start.sh`, set `ALL_LOCAL=TRUE` and set `WHISPER_MODEL_PATH` to the path of the model. + ## Usage ```bash @@ -30,7 +32,6 @@ cd OS/01 bash start.sh ``` -If you want to run local text-to-speech and speech-to-text, set `ALL_LOCAL` in the `start.sh` script to True. This will use the [whisper.cpp](https://github.com/ggerganov/whisper.cpp) and [Piper](https://github.com/rhasspy/piper) models.
## Background