#!/bin/bash # ============================================================================= # Vosk German Model Download Script # ============================================================================= # This script downloads and sets up the vosk-model-de-0.22 model for German speech recognition. # # Requirements: # - wget (for downloading) # - unzip (for extraction) # - ~500MB free disk space # # Usage: # ./download-vosk-model.sh [target-directory] # # Example: # ./download-vosk-model.sh ./models/vosk # ./download-vosk-model.sh /opt/vosk # ============================================================================= set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Default values MODEL_NAME="vosk-model-de-0.22" MODEL_URL="https://alphacephei.com/vosk/models/${MODEL_NAME}.zip" DEFAULT_TARGET="./models/vosk" # Parse arguments TARGET_DIR="${1:-$DEFAULT_TARGET}" # Function to print colored output print_status() { echo -e "${BLUE}[INFO]${NC} $1" } print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } echo "==========================================" echo "Vosk German Model Setup" echo "==========================================" echo "" # Check if wget is installed if ! command -v wget &> /dev/null; then print_error "wget is not installed. Please install it first." print_status "On Ubuntu/Debian: sudo apt-get install wget" print_status "On CentOS/RHEL: sudo yum install wget" print_status "On macOS: brew install wget" exit 1 fi # Check if unzip is installed if ! command -v unzip &> /dev/null; then print_error "unzip is not installed. Please install it first." print_status "On Ubuntu/Debian: sudo apt-get install unzip" print_status "On CentOS/RHEL: sudo yum install unzip" print_status "On macOS: Already included" exit 1 fi # Create target directory print_status "Creating target directory: ${TARGET_DIR}" mkdir -p "${TARGET_DIR}" # Change to target directory cd "${TARGET_DIR}" # Download the model print_status "Downloading ${MODEL_NAME}.zip from ${MODEL_URL}" print_status "This may take a while depending on your internet connection..." wget "${MODEL_URL}" -O "${MODEL_NAME}.zip" # Verify download if [ ! -f "${MODEL_NAME}.zip" ]; then print_error "Failed to download model file" exit 1 fi print_success "Download completed!" # Extract the model print_status "Extracting model..." unzip "${MODEL_NAME}.zip" # Clean up zip file print_status "Cleaning up..." rm "${MODEL_NAME}.zip" # Verify extraction if [ ! -d "${MODEL_NAME}" ]; then print_error "Failed to extract model" exit 1 fi print_success "Model extracted successfully!" # Verify model files MODEL_DIR="${TARGET_DIR}/${MODEL_NAME}" if [ -f "${MODEL_DIR}/model" ] && [ -f "${MODEL_DIR}/ivector" ]; then print_success "Model files verified!" else print_warning "Model directory created but expected files not found" print_status "Expected files: model, ivector, conf/" fi echo "" echo "==========================================" echo "Setup Complete!" echo "==========================================" echo "" print_success "Vosk model ${MODEL_NAME} is ready at: ${MODEL_DIR}" echo "" print_status "Next steps:" print_status "1. Update appsettings.json:" print_status " \"Vosk\": { \"ModelPath\": \"${TARGET_DIR}/${MODEL_NAME}\" }" echo "" print_status "2. Install Vosk Python package:" print_status " pip install vosk" echo "" print_status "3. Verify with:" print_status " python3 -c \"from vosk import Model; Model('${TARGET_DIR}/${MODEL_NAME}'); print('OK')\"" echo ""