A Docker-based speech-to-text service using VOSK with support for Vietnamese and English languages.
515
A Docker-based speech-to-text service using VOSK with support for Vietnamese and English languages.
Image: truongginjs/stt
# Pull and run the pre-built image
docker run -p 8000:8000 truongginjs/stt:latest
# Or use Docker Compose
docker-compose up
Clone and navigate to the project directory:
cd /path/to/stt
Build and run with Docker Compose:
docker-compose up --build
Access the service:
curl -X POST "http://localhost:8000/transcribe" \
-F "file=@your_audio.wav" \
-F "language=vi"
const ws = new WebSocket('ws://localhost:8000/ws/en');
// Send audio data as binary
ws.send(audioBuffer);
curl http://localhost:8000/languages
en - English (US)vi - VietnameseNavigate to http://localhost:8000 and use the built-in interface to:
Vietnamese transcription:
curl -X POST "http://localhost:8000/transcribe" \
-F "file=@vietnamese_audio.mp3" \
-F "language=vi"
English transcription:
curl -X POST "http://localhost:8000/transcribe" \
-F "file=@english_audio.wav" \
-F "language=en"
import requests
# Upload file for transcription
with open('audio.wav', 'rb') as f:
files = {'file': f}
data = {'language': 'vi'}
response = requests.post('http://localhost:8000/transcribe',
files=files, data=data)
result = response.json()
print(result['text'])
const ws = new WebSocket('ws://localhost:8000/ws/en');
ws.onopen = () => {
console.log('Connected to STT service');
};
ws.onmessage = (event) => {
const result = JSON.parse(event.data);
console.log('Transcription:', result.text);
};
// Send audio data
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
const mediaRecorder = new MediaRecorder(stream);
mediaRecorder.ondataavailable = (event) => {
ws.send(event.data);
};
mediaRecorder.start(1000); // Send data every second
});
{
"success": true,
"language": "vi",
"text": "Xin chào, tôi là trợ lý ảo",
"detailed_results": [...],
"confidence": 0.95
}
{
"success": false,
"error": "Error message"
}
MODELS_DIR: Directory containing VOSK models (default: /app/models)PYTHONUNBUFFERED: Set to 1 for immediate log outputTo use different VOSK models, modify the Dockerfile to download your preferred models:
# Add custom model download
RUN wget -O /tmp/your-custom-model.zip https://your-model-url.zip && \
unzip /tmp/your-custom-model.zip -d /app/models/ && \
mv /app/models/your-model-folder /app/models/custom && \
rm /tmp/your-custom-model.zip
The project includes a comprehensive management script run.sh for easy operations:
# Build the Docker image
./run.sh build
# Start the service
./run.sh start
# View logs
./run.sh logs
# Test the service
./run.sh test
# Build and publish to Docker Hub
./run.sh publish
# Publish with a specific version
./run.sh publish v1.0
# Stop the service
./run.sh stop
Login to Docker Hub:
docker login
Build and push:
./run.sh publish # Pushes as latest
./run.sh publish v1.0 # Pushes as v1.0
Or manually:
docker build -t truongginjs/stt:latest .
docker push truongginjs/stt:latest
If you want to use a different Docker Hub username, you can:
Update docker-compose.yml:
image: yourusername/stt:latest
Update the IMAGE_NAME in run.sh:
IMAGE_NAME="yourusername/stt"
Install dependencies:
pip install -r requirements.txt
Download models manually:
mkdir -p models
# Download and extract VOSK models to models/vi and models/en
Run locally:
python app.py
models dictionary in app.py/languages endpointView container logs:
docker-compose logs -f vosk-stt
curl http://localhost:8000/health
This project uses VOSK (Apache 2.0 License) and is intended for educational and commercial use.
For better accuracy, consider using larger models (vosk-model-vi or vosk-model-en-us).
Content type
Image
Digest
sha256:9369cd021…
Size
379.1 MB
Last updated
about 1 year ago
docker pull truongginjs/stt