Simple CLI tool in Rust for automatic subtitle generation. Both transcription and translation are supported.
- Speech-to-text: NVIDIA Canary
- Text translation: Google TranslateGemma
FFmpeg.
It's best to pre-download models from HuggingFace using the CLI:
hf download istupakov/canary-1b-v2-onnx
hf download onnx-community/translategemma-text-4b-it-ONNXTo generate subtitles for a video file, run the following commands:
# Transcribe video to SRT
autosrt --input video.mp4 --model istupakov/canary-1b-v2-onnx
# Translate existing SRT file
autosrt --input subtitles.srt --translate-model onnx-community/translategemma-text-4b-it-ONNX
# Transcribe and translate in one step
autosrt --input video.mp4 --model istupakov/canary-1b-v2-onnx --translate-model onnx-community/translategemma-text-4b-it-ONNX| Option | Short | Description | Default |
|---|---|---|---|
--input |
-i |
Input video file or SRT file | (required) |
--output |
-o |
Output SRT file path | Input filename with .srt extension |
--model |
-m |
Path or ID of Canary model | (required for video transcription) |
--translate-model |
-t |
Path or ID of TranslateGemma model | (optional, enables translation) |
--source-lang |
-s |
Source language code for translation | fi |
--target-lang |
-l |
Target language code for translation | en |
--debug |
-d |
Save downsampled audio to file for debugging | (off) |
# Transcribe Finnish video to English subtitles
autosrt -i video.mp4 -m istupakov/canary-1b-v2-onnx
# Transcribe and translate from Finnish to German
autosrt -i video.mp4 -m istupakov/canary-1b-v2-onnx -t onnx-community/translategemma-text-4b-it-ONNX -s fi -l de
# Translate existing SRT from Spanish to English
autosrt -i subtitles.srt -t onnx-community/translategemma-text-4b-it-ONNX -s es -l en -o translated.srt
# Custom output path
autosrt -i video.mp4 -m istupakov/canary-1b-v2-onnx -o custom_subtitles.srt
# Save debug audio files
autosrt -i video.mp4 -m istupakov/canary-1b-v2-onnx -dCommon language codes:
| Code | Language | Code | Language |
|---|---|---|---|
en |
English | de |
German |
fi |
Finnish | es |
Spanish |
sv |
Swedish | fr |
French |
no |
Norwegian | it |
Italian |
da |
Danish | pt |
Portuguese |
ru |
Russian | ja |
Japanese |
zh |
Chinese | ko |
Korean |
ar |
Arabic | hi |
Hindi |