This project implements an Automatic Speech Recognition (ASR) service using FastAPI, Faster Whisper model, and MySQL database. It provides endpoints to transcribe audio files and retrieve statistics.
. ├── Dockerfile ├── README.md ├── app │ ├── main.py # FastAPI application entry point, defines API endpoints. │ ├── models.py # Defines database models and configurations. │ ├── stats.py # Functions for handling statistics storage and retrieval. │ └── transcriber.py # Logic for transcribing audio using Faster Whisper. ├── k8s │ ├── app-configmap.yaml # Kubernetes ConfigMap for environment variables. │ ├── app-deployment.yaml # Deployment configuration for FastAPI application. │ ├── app-service.yaml # Service configuration to expose FastAPI. │ ├── app-tests-pod.yaml # Pod definition for running tests. │ ├── mysql-deployment.yaml # Deployment and service for MySQL database. │ └── storage-retain.yaml # Persistent storage class for MySQL. ├── requirements.txt # Python dependencies. └── tests ├── ch1.mp3 # Sample audio file for tests. ├── test_endpoints.py # Functional tests for API endpoints. ├── test_stats.py # Tests statistics functionality. ├── test_transcriber.py # Tests transcription functionality. └── test_unit.py # Unit tests for internal logic.
- Follow official instructions: https://docs.docker.com/desktop/windows/wsl/
- Follow official instructions: https://minikube.sigs.k8s.io/docs/start/
- Follow official instructions: https://kubernetes.io/docs/tasks/tools/
Clone the repository:
git clone <repo-url>
cd <project-directory>
Build the Docker image:
make build
Deploy to Minikube:
make deploy
Run tests in Kubernetes (they run authomatically after deployment in a separate test pod):
make test
View test results:
kubectl logs asr-api-tests
- Verify internal logic for statistics calculation and database interaction (mocked DB interactions).
- Test FastAPI endpoints:
/transcribe_audio: Ensures audio transcription works correctly./stats: Validates retrieval of statistics.
- Transcription functionality is validated using an audio file (
ch1.mp3).
Results are accessible through the test pod logs.
MySQL was selected over Redis to ensure data persistence across Minikube restarts or pod deletions.
-
Exposes two endpoints:
/transcribe_audio: Accepts audio and returns transcribed text./stats: Provides service usage statistics.
-
Service can be tested easily using a graphical web interface via NodePort service.
Access the graphical interface (after deployment):
minikube service asr-api