fix: compile Rust binary in start script if needed, added check if Rust installed
This commit is contained in:
		
							parent
							
								
									a190387b34
								
							
						
					
					
						commit
						d12bc644ca
					
				| 
						 | 
					@ -57,7 +57,7 @@ def run_command(command):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_transcription_file(wav_file_path: str):
 | 
					def get_transcription_file(wav_file_path: str):
 | 
				
			||||||
    local_path = os.path.join(os.path.dirname(__file__), 'local_service')
 | 
					    local_path = os.path.join(os.path.dirname(__file__), 'local_service')
 | 
				
			||||||
    whisper_rust_path = os.path.join(os.path.dirname(__file__), 'whisper-rust')
 | 
					    whisper_rust_path = os.path.join(os.path.dirname(__file__), 'whisper-rust', 'target', 'release')
 | 
				
			||||||
    model_name = os.getenv('WHISPER_MODEL_NAME')
 | 
					    model_name = os.getenv('WHISPER_MODEL_NAME')
 | 
				
			||||||
    if not model_name:
 | 
					    if not model_name:
 | 
				
			||||||
        raise EnvironmentError("WHISPER_MODEL_NAME environment variable is not set.")
 | 
					        raise EnvironmentError("WHISPER_MODEL_NAME environment variable is not set.")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
# Setup
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
To rebuild the `whisper-rust` executable, do the following:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
1. Install [Rust](https://www.rust-lang.org/tools/install), cmake, and Python dependencies `pip install -r requirements.txt`.
 | 
					 | 
				
			||||||
2. Go to **core/stt** and run `cargo build --release`.
 | 
					 | 
				
			||||||
3. Move the `whisper-rust` executable from target/release to this directory.
 | 
					 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -71,12 +71,33 @@ if [[ "$ALL_LOCAL" == "True" ]]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## WHISPER
 | 
					    ## WHISPER
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    WHISPER_PATH="$SCRIPT_DIR/01OS/server/stt/local_service"
 | 
					    CWD=$(pwd)
 | 
				
			||||||
    if [[ ! -f "${WHISPER_PATH}/${WHISPER_MODEL_NAME}" ]]; then
 | 
					
 | 
				
			||||||
        mkdir -p "${WHISPER_PATH}"
 | 
					    STT_PATH="$SCRIPT_DIR/01OS/server/stt"
 | 
				
			||||||
        curl -L "${WHISPER_MODEL_URL}${WHISPER_MODEL_NAME}" -o "${WHISPER_PATH}/${WHISPER_MODEL_NAME}"
 | 
					    WHISPER_RUST_PATH="${STT_PATH}/whisper-rust"
 | 
				
			||||||
 | 
					    cd ${WHISPER_RUST_PATH}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Check if whisper-rust executable exists
 | 
				
			||||||
 | 
					    if [[ ! -f "${WHISPER_RUST_PATH}/target/release/whisper-rust" ]]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Check if Rust is installed. Needed to build whisper executable
 | 
				
			||||||
 | 
					        if ! command -v rustc &> /dev/null; then
 | 
				
			||||||
 | 
					            echo "Rust is not installed or is not in system PATH. Please install Rust before proceeding."
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Build the Whisper Rust executable
 | 
				
			||||||
 | 
					        cargo build --release
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    WHISPER_MODEL_PATH="${STT_PATH}/local_service"
 | 
				
			||||||
 | 
					    if [[ ! -f "${WHISPER_MODEL_PATH}/${WHISPER_MODEL_NAME}" ]]; then
 | 
				
			||||||
 | 
					        mkdir -p "${WHISPER_MODEL_PATH}"
 | 
				
			||||||
 | 
					        curl -L "${WHISPER_MODEL_URL}${WHISPER_MODEL_NAME}" -o "${WHISPER_MODEL_PATH}/${WHISPER_MODEL_NAME}"
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cd $CWD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ## PIPER
 | 
					    ## PIPER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PIPER_FOLDER_PATH="$SCRIPT_DIR/01OS/server/tts/local_service"
 | 
					    PIPER_FOLDER_PATH="$SCRIPT_DIR/01OS/server/tts/local_service"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,6 +20,8 @@ brew install portaudio ffmpeg
 | 
				
			||||||
sudo apt-get install portaudio19-dev ffmpeg
 | 
					sudo apt-get install portaudio19-dev ffmpeg
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you want to run local speech-to-text using Whisper, install Rust. Follow the instructions given [here](https://www.rust-lang.org/tools/install).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Setup for usage (experimental):
 | 
					## Setup for usage (experimental):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue