Skip to the content.

Lopatnov.Translate

Self-hosted speech and text translation service. .NET 10 · gRPC · ONNX Runtime · Docker.

CI License: Apache 2.0 GitHub issues GitHub stars

A self-hosted gRPC service for text translation, language detection, and speech-to-text transcription. All models run locally — no cloud dependencies. Multiple models can be configured by name and selected per request.


Getting Started

1. Clone

git clone https://github.com/lopatnov/translate.git
cd translate

2. Download models

Download the default translation and STT models:

# Translation model — see docs/models.md for all options
huggingface-cli download lopatnov/m2m100_418M-onnx --local-dir ./models/translate/m2m100_418M

# Speech-to-text (Whisper small, ~500 MB)
huggingface-cli download lopatnov/whisper.cpp ggml-small.bin --local-dir ./models/audio-to-text/whisper.cpp

See docs/models.md for all available models and configuration.

3. Start

docker compose -f docker/docker-compose.yml up --build

4. Translate text

grpcurl -plaintext \
  -d '{"text":"Hello","source_language":"en","target_language":"uk"}' \
  localhost:5100 lopatnov.translate.v1.TranslateService/TranslateText

5. Transcribe audio

# Linux
grpcurl -plaintext \
  -d "{\"audio_data\": \"$(base64 -w0 my-audio.wav)\", \"language\": \"auto\"}" \
  localhost:5100 lopatnov.translate.v1.TranslateService/TranscribeAudio

# macOS (base64 has no -w flag)
grpcurl -plaintext \
  -d "{\"audio_data\": \"$(base64 my-audio.wav | tr -d '\n')\", \"language\": \"auto\"}" \
  localhost:5100 lopatnov.translate.v1.TranslateService/TranscribeAudio

The gRPC server runs on port 5100. See docs/api.md for the full API reference.


Documentation

Doc Description
docs/api.md gRPC API reference — RPCs, messages, examples
docs/models.md Model setup — download, configuration, licenses
docs/deployment.md Docker deployment
docs/development.md Local dev, build, testing

Project Structure

src/
  Lopatnov.Translate.Grpc/           # gRPC server, DI wiring, model registry
  Lopatnov.Translate.Core/           # interfaces, language detection, JSON localization
  Lopatnov.Translate.Nllb/           # NLLB-200 translator (ONNX Runtime)
  Lopatnov.Translate.M2M100/         # M2M-100 translator (ONNX Runtime)
  Lopatnov.Translate.Whisper/        # Whisper speech-to-text (Whisper.net)
  Lopatnov.Translate.LibreTranslate/ # LibreTranslate HTTP client

tests/
  Lopatnov.Translate.Grpc.Tests/     # service dispatch, model session manager
  Lopatnov.Translate.Core.Tests/     # language detection, JSON localization
  Lopatnov.Translate.Nllb.Tests/     # tokenizer, translator, integration
  Lopatnov.Translate.M2M100.Tests/   # tokenizer, translator, integration
  Lopatnov.Translate.Whisper.Tests/  # audio resampling, recognizer, integration

models/                              # gitignored — populate via huggingface-cli (see docs/models.md)
  translate/                         # M2M-100, NLLB ONNX files
  detect-lang/                       # FastText LID-176, GlotLID
  audio-to-text/                     # Whisper ggml files
  text-to-audio/                     # Piper voice files

docker/
  Dockerfile
  docker-compose.yml

Contributing

Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request.


License

Apache 2.0 © 2026 Oleksandr Lopatnov · LinkedIn