Skip to content

stt-ru

stt-ru

stt-ru is a tool for Russian speech recognition: a Python library, the stt-ru command, a web interface with a REST API and a Docker image. Speech is recognized by the GigaAM-v3 model through onnx-asr: the text comes with punctuation and digits, the channels of a stereo recording are recognized as separate speakers, and the result is saved as subtitles and tables.

Features

  • transcribe files and folders from the command line: text to the console or the results of every file to a folder, one summary file for a whole batch, monitoring a folder for new recordings
  • save the result in the formats TXT, JSON, JSONL, SRT, VTT, ASS and CSV
  • transcribe recordings from files and from memory in a Python program
  • choose the onnx-asr model, the device and the speech detection parameters
  • evaluate the quality of models on your own references: word (WER) and character (CER) error rates, speed
  • run a web interface and REST API for yourself or a team
  • run all of it in Docker, including NVIDIA GPUs

Installation

Python 3.11 or newer is required.

pip install stt-ru

The extras for formats via ffmpeg, the web service and quality evaluation, GPUs and the model cache are described on the Installation page.

Quick start

stt-ru transcribe call.wav                     # text to the console
stt-ru transcribe calls/ -o out/ -f srt,csv    # results of every file in out/
stt-ru serve                                   # web interface at http://127.0.0.1:8000
>>> from stt_ru import Transcriber

>>> result = Transcriber().transcribe("call.wav")
>>> for segment in result.segments:
...     print(segment.speaker, segment.start, segment.end, segment.text)
Канал 1 0.994 9.054 Наталья, благодарю вас за ожидание. По данному вопросу я сейчас ваш звонок переведу на специалиста профильного подразделения. Оставайтесь, пожалуйста, на линии.
Канал 0 3.49 3.934 Угу
Канал 0 7.682 8.222 Угу
Канал 1 9.634 12.638 Я в свою очередь с вами прощаюсь. Всего доброго, до свидания.
Канал 0 12.994 13.662 До свидания.

>>> result.save("call.srt")
PosixPath('call.srt')

On the first run the model (about 230 MB) is downloaded from Hugging Face. More examples are in the notebooks.

How it works

  1. The file is read entirely: WAV, FLAC, OGG, MP3 and other uncompressed formats by the soundfile library, M4A, AAC, AMR, WMA and the sound of videos by ffmpeg.
  2. The channels of a stereo recording are recognized separately: in a recorded conversation each channel is its own speaker ("Канал 0", "Канал 1", that is "Channel 0", "Channel 1"). Channels that differ only in loudness and a small delay are recognized once.
  3. Silero VAD speech detection cuts the recording into speech segments of at most 20 s, and the model recognizes each segment.
  4. The result is a list of segments with start, end, channel and text ordered by start time. Recordings longer than 10 minutes are recognized in windows of about 10 minutes cut at a pause, so recognition needs less memory.

Version 0.2

The previous Kaldi version is no longer developed. Its code remains in the repository history.