Livrare LOT 1 - Didi
This commit is contained in:
commit
5380c3fc63
990 changed files with 133308 additions and 0 deletions
40
ai_platform/modules/audio/deploy/Dockerfile
Normal file
40
ai_platform/modules/audio/deploy/Dockerfile
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# Audio Transcription Service - Dockerfile
|
||||
# Uses faster-whisper for optimized speech-to-text transcription
|
||||
|
||||
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
|
||||
|
||||
# Prevent interactive prompts during build
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Europe/Bucharest
|
||||
|
||||
# Install Python 3.10 (default in Ubuntu 22.04) and system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-dev \
|
||||
curl \
|
||||
ffmpeg \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf /usr/bin/python3 /usr/bin/python
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy project files
|
||||
COPY pyproject.toml /app/
|
||||
COPY src/ /app/src/
|
||||
|
||||
# Install Python dependencies
|
||||
RUN pip install --no-cache-dir -e .
|
||||
|
||||
# Create cache directory
|
||||
RUN mkdir -p /root/.cache/huggingface
|
||||
|
||||
# Default port
|
||||
ENV AUDIO_PORT=54300
|
||||
|
||||
# Expose port
|
||||
EXPOSE 54300
|
||||
|
||||
# Run FastAPI with uvicorn
|
||||
CMD python -m uvicorn audio.app:app --host 0.0.0.0 --port ${AUDIO_PORT}
|
||||
116
ai_platform/modules/audio/deploy/deploy.sh
Normal file
116
ai_platform/modules/audio/deploy/deploy.sh
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Docker Compose Startup Script for Audio Transcription
|
||||
#
|
||||
# Usage: ./deploy/deploy.sh [OPTIONS]
|
||||
#
|
||||
# Options:
|
||||
# --profile <api|api-nginx> Docker compose profile
|
||||
# --detach Run in detached mode
|
||||
# --down Stop and remove containers
|
||||
# --logs Show logs
|
||||
# --help Show this help message
|
||||
#
|
||||
# Required: Set environment variables in deploy/.env file or export them before running.
|
||||
# See ../.env.example (module root) for the full list of variables.
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Load .env file ONLY from deploy/ directory
|
||||
if [[ -f "$SCRIPT_DIR/.env" ]]; then
|
||||
echo "Loading environment from: $SCRIPT_DIR/.env"
|
||||
set -a
|
||||
source "$SCRIPT_DIR/.env"
|
||||
set +a
|
||||
fi
|
||||
|
||||
PROFILE=""
|
||||
DETACH=""
|
||||
ACTION="up"
|
||||
|
||||
show_help() {
|
||||
sed -n '2,18p' "$0" | sed 's/^# //' | sed 's/^#//'
|
||||
exit 0
|
||||
}
|
||||
|
||||
check_required_var() {
|
||||
local var_name="$1"
|
||||
if [[ -z "${!var_name:-}" ]]; then
|
||||
echo "ERROR: Required environment variable $var_name is not set"
|
||||
echo "Set it in deploy/.env file or export it before running this script"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--profile)
|
||||
PROFILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--detach|-d)
|
||||
DETACH="-d"
|
||||
shift
|
||||
;;
|
||||
--down)
|
||||
ACTION="down"
|
||||
shift
|
||||
;;
|
||||
--logs)
|
||||
ACTION="logs"
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Use --help for usage information"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Require profile when bringing up
|
||||
if [[ -z "$PROFILE" && "$ACTION" == "up" ]]; then
|
||||
echo "ERROR: --profile is required"
|
||||
echo "Options: api, api-nginx"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fail-fast required vars
|
||||
check_required_var "AUDIO_MODEL"
|
||||
check_required_var "AUDIO_DEVICE"
|
||||
check_required_var "AUDIO_CACHE_DIR"
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
case $ACTION in
|
||||
up)
|
||||
echo "Starting Audio Transcription API with profile: $PROFILE"
|
||||
echo " Model: $AUDIO_MODEL"
|
||||
echo " Device: $AUDIO_DEVICE"
|
||||
echo " Compute type: ${AUDIO_COMPUTE_TYPE:-int8}"
|
||||
echo " Cache dir: $AUDIO_CACHE_DIR"
|
||||
echo ""
|
||||
# shellcheck disable=SC2086
|
||||
exec docker compose --profile "$PROFILE" up $DETACH
|
||||
;;
|
||||
down)
|
||||
if [[ -z "$PROFILE" ]]; then
|
||||
echo "ERROR: --profile is required with --down"
|
||||
exit 1
|
||||
fi
|
||||
echo "Stopping Audio Transcription containers..."
|
||||
exec docker compose --profile "$PROFILE" down
|
||||
;;
|
||||
logs)
|
||||
if [[ -z "$PROFILE" ]]; then
|
||||
echo "ERROR: --profile is required with --logs"
|
||||
exit 1
|
||||
fi
|
||||
exec docker compose --profile "$PROFILE" logs -f
|
||||
;;
|
||||
esac
|
||||
95
ai_platform/modules/audio/deploy/docker-compose.yml
Normal file
95
ai_platform/modules/audio/deploy/docker-compose.yml
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# Audio Module - Docker Compose Configuration
|
||||
#
|
||||
# Port Allocation (Dev AI Audio: 54300):
|
||||
# 54300 - Audio API (Whisper STT service)
|
||||
#
|
||||
# Profiles:
|
||||
# api - API server only
|
||||
#
|
||||
# Required environment variables (set in deploy/.env file):
|
||||
# AUDIO_MODEL - Whisper model name (e.g., large-v3-turbo)
|
||||
# AUDIO_DEVICE - Device: cuda or cpu
|
||||
# AUDIO_COMPUTE_TYPE - Compute type: int8, float16, int8_float16
|
||||
# AUDIO_CACHE_DIR - Model cache directory
|
||||
#
|
||||
# GPU Configuration:
|
||||
# - Runs on GPU 0 (shared with Qwen3.5-35B-A3B)
|
||||
# - Requires ~6GB VRAM for large-v3-turbo with int8
|
||||
#
|
||||
# Naming Convention: didiAI-{module}-{service}
|
||||
#
|
||||
# Network:
|
||||
# Uses deploy_default network (shared with other modules)
|
||||
|
||||
networks:
|
||||
deploy_default:
|
||||
external: true
|
||||
|
||||
services:
|
||||
# ==========================================================================
|
||||
# Audio Transcription API Server
|
||||
# ==========================================================================
|
||||
audio-api:
|
||||
container_name: didiAI-audio-api
|
||||
image: didiai-audio-api
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: deploy/Dockerfile
|
||||
|
||||
ports:
|
||||
- "54300:54300"
|
||||
networks:
|
||||
- deploy_default
|
||||
|
||||
environment:
|
||||
# GPU configuration
|
||||
- CUDA_VISIBLE_DEVICES=0
|
||||
|
||||
# External URL for OpenAPI spec (REQUIRED)
|
||||
- AUDIO_EXTERNAL_URL=${AUDIO_EXTERNAL_URL}
|
||||
|
||||
# Whisper model configuration
|
||||
- AUDIO_MODEL=${AUDIO_MODEL:-large-v3-turbo}
|
||||
- AUDIO_DEVICE=${AUDIO_DEVICE:-cuda}
|
||||
- AUDIO_COMPUTE_TYPE=${AUDIO_COMPUTE_TYPE:-int8}
|
||||
- AUDIO_CACHE_DIR=${AUDIO_CACHE_DIR:-/root/.cache/huggingface}
|
||||
|
||||
# Transcription settings
|
||||
- AUDIO_BEAM_SIZE=${AUDIO_BEAM_SIZE:-5}
|
||||
- AUDIO_BEST_OF=${AUDIO_BEST_OF:-5}
|
||||
- AUDIO_TEMPERATURE=${AUDIO_TEMPERATURE:-0.0}
|
||||
|
||||
# Server settings
|
||||
- AUDIO_HOST=0.0.0.0
|
||||
- AUDIO_PORT=54300
|
||||
- AUDIO_LOG_LEVEL=${AUDIO_LOG_LEVEL:-INFO}
|
||||
|
||||
# Runtime config polling
|
||||
- AUDIO_DASHBOARD_URL=${AUDIO_DASHBOARD_URL:-http://didiAI-dashboard:51300}
|
||||
|
||||
# Upload limits
|
||||
- AUDIO_MAX_FILE_SIZE_MB=${AUDIO_MAX_FILE_SIZE_MB:-500}
|
||||
|
||||
volumes:
|
||||
# Model cache (shared with other modules)
|
||||
- ${AUDIO_CACHE_DIR:-/root/.cache/huggingface}:/root/.cache/huggingface
|
||||
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
device_ids: ['0']
|
||||
capabilities: [gpu]
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:54300/health')"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
restart: unless-stopped
|
||||
profiles:
|
||||
- api
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue