From 4e3c1f77a6927f1fc538f7dee574159de6a59112 Mon Sep 17 00:00:00 2001 From: Shiven Mian Date: Fri, 16 Feb 2024 03:34:26 -0800 Subject: [PATCH] fix: re-add whisper-rust source code, modify scripts --- 01OS/.env.example | 1 + 01OS/01OS/server/stt/local_service/.DS_Store | Bin 6148 -> 0 bytes .../01OS/server/stt/local_service/__init__.py | 0 01OS/01OS/server/stt/stt.py | 2 +- .../whisper-rust/.gitignore | 0 .../whisper-rust/Cargo.lock | 0 .../whisper-rust/Cargo.toml | 0 .../whisper-rust/README.md | 0 .../whisper-rust/src/main.rs | 0 .../whisper-rust/src/transcribe.rs | 0 .../whisper-rust/whisper-rust | Bin .../01OS/server/tts/local_service/__init__.py | 0 01OS/start.sh | 19 +++++++++++++----- 13 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 01OS/01OS/server/stt/local_service/.DS_Store delete mode 100644 01OS/01OS/server/stt/local_service/__init__.py rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/.gitignore (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/Cargo.lock (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/Cargo.toml (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/README.md (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/src/main.rs (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/src/transcribe.rs (100%) rename 01OS/01OS/server/stt/{local_service => }/whisper-rust/whisper-rust (100%) delete mode 100644 01OS/01OS/server/tts/local_service/__init__.py diff --git a/01OS/.env.example b/01OS/.env.example index 388ae53..0b80c82 100644 --- a/01OS/.env.example +++ b/01OS/.env.example @@ -5,6 +5,7 @@ # else we use whisper.cpp and piper local models ALL_LOCAL=False WHISPER_MODEL_NAME="ggml-tiny.en.bin" +WHISPER_MODEL_URL="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/" # Uncomment to set your OpenAI API key # OPENAI_API_KEY=sk-... diff --git a/01OS/01OS/server/stt/local_service/.DS_Store b/01OS/01OS/server/stt/local_service/.DS_Store deleted file mode 100644 index c18108c48d01767c8f2c03564603ed15faf0617a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyG{c^3>-s>NKmAt+#jIe4^~n5g8Tpl2#`=f34!*id{;h=@k2LiOI;@5dt0!AcC>BrW{VmF2 zJyB5#NP)2e=eb>Y|G%aGF#nH9+DQQ^@UIlG*=oI7@|CK$PF~J?ZKL1Oz2-=F<2on| m(T<7Hj=Ax6d=*7m*L=^)ukQ$fUquEAR!$;1)~( diff --git a/01OS/01OS/server/stt/local_service/__init__.py b/01OS/01OS/server/stt/local_service/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/01OS/01OS/server/stt/stt.py b/01OS/01OS/server/stt/stt.py index b235a8f..9ee0999 100644 --- a/01OS/01OS/server/stt/stt.py +++ b/01OS/01OS/server/stt/stt.py @@ -57,7 +57,7 @@ def run_command(command): def get_transcription_file(wav_file_path: str): local_path = os.path.join(os.path.dirname(__file__), 'local_service') - whisper_rust_path = os.path.join(local_path, 'whisper-rust') + whisper_rust_path = os.path.join(os.path.dirname(__file__), 'whisper-rust') model_name = os.getenv('WHISPER_MODEL_NAME') if not model_name: raise EnvironmentError("WHISPER_MODEL_NAME environment variable is not set.") diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/.gitignore b/01OS/01OS/server/stt/whisper-rust/.gitignore similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/.gitignore rename to 01OS/01OS/server/stt/whisper-rust/.gitignore diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/Cargo.lock b/01OS/01OS/server/stt/whisper-rust/Cargo.lock similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/Cargo.lock rename to 01OS/01OS/server/stt/whisper-rust/Cargo.lock diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/Cargo.toml b/01OS/01OS/server/stt/whisper-rust/Cargo.toml similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/Cargo.toml rename to 01OS/01OS/server/stt/whisper-rust/Cargo.toml diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/README.md b/01OS/01OS/server/stt/whisper-rust/README.md similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/README.md rename to 01OS/01OS/server/stt/whisper-rust/README.md diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/src/main.rs b/01OS/01OS/server/stt/whisper-rust/src/main.rs similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/src/main.rs rename to 01OS/01OS/server/stt/whisper-rust/src/main.rs diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/src/transcribe.rs b/01OS/01OS/server/stt/whisper-rust/src/transcribe.rs similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/src/transcribe.rs rename to 01OS/01OS/server/stt/whisper-rust/src/transcribe.rs diff --git a/01OS/01OS/server/stt/local_service/whisper-rust/whisper-rust b/01OS/01OS/server/stt/whisper-rust/whisper-rust similarity index 100% rename from 01OS/01OS/server/stt/local_service/whisper-rust/whisper-rust rename to 01OS/01OS/server/stt/whisper-rust/whisper-rust diff --git a/01OS/01OS/server/tts/local_service/__init__.py b/01OS/01OS/server/tts/local_service/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/01OS/start.sh b/01OS/start.sh index 2db9140..9409853 100755 --- a/01OS/start.sh +++ b/01OS/start.sh @@ -54,6 +54,16 @@ if [[ "$@" == *"--expose"* ]]; then export SERVER_EXPOSE_PUBLICALLY="True" fi +# Check if "--clear-local" is passed as an argument +if [[ "$@" == *"--clear-local"* ]]; then + # If "--clear-local" is passed, clear the contents of the folders in script_dir/01OS/server/{tts and stt}/local_service + echo "Clearing local services..." + rm -rf "$SCRIPT_DIR/01OS/server/tts/local_service"/* + rm -rf "$SCRIPT_DIR/01OS/server/stt/local_service"/* + echo "Exiting after clearing local services..." + exit 0 +fi + ### SETUP if [[ "$ALL_LOCAL" == "True" ]]; then @@ -61,7 +71,6 @@ if [[ "$ALL_LOCAL" == "True" ]]; then ## WHISPER - WHISPER_MODEL_URL="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/" WHISPER_PATH="$SCRIPT_DIR/01OS/server/stt/local_service" if [[ ! -f "${WHISPER_PATH}/${WHISPER_MODEL_NAME}" ]]; then mkdir -p "${WHISPER_PATH}" @@ -70,10 +79,10 @@ if [[ "$ALL_LOCAL" == "True" ]]; then ## PIPER - PIPER_FILE_PATH="$SCRIPT_DIR/01OS/server/tts/local_service${PIPER_URL}${PIPER_ASSETNAME}" - if [[ ! -f "$PIPER_FILE_PATH" ]]; then + PIPER_FOLDER_PATH="$SCRIPT_DIR/01OS/server/tts/local_service" + if [[ ! -f "$PIPER_FOLDER_PATH" ]]; then - mkdir -p "${PIPER_FILE_PATH}" + mkdir -p "${PIPER_FOLDER_PATH}" OS=$(uname -s) ARCH=$(uname -m) @@ -94,7 +103,7 @@ if [[ "$ALL_LOCAL" == "True" ]]; then CWD=$(pwd) # Navigate to SCRIPT_DIR/01OS/server/tts/local_service - cd $SCRIPT_DIR/01OS/server/tts/local_service + cd ${PIPER_FOLDER_PATH} curl -L "${PIPER_URL}${PIPER_ASSETNAME}" -o "${PIPER_ASSETNAME}" tar -xvzf $PIPER_ASSETNAME