Skip to main content

Retro Russian speech synthesizer (ru_tts) wrapped for Python

Project description

retro-ru-tts

Читать на русском | GitHub

Python wrapper for the ru_tts speech synthesizer — a compact, portable Russian TTS engine written in pure C.

The core is a reverse-engineered reimplementation of the SDRV resident speech driver (BelSInt lab, Institute of Technical Cybernetics, Academy of Sciences of the Byelorussian SSR, 1990). It uses formant (diphone) synthesis: no ML models, no GPU, no large dependencies — just simple, fast, deterministic speech generation.

Quick start

pip install retro-ru-tts

# Optional: ru-normalizr for advanced normalization (Python ≥ 3.10)
pip install retro-ru-tts[normalize]
import retro_ru_tts

# Synthesize and play through speakers
retro_ru_tts.synthesize("Привет, мир!")

# Get raw PCM data without playing
pcm = retro_ru_tts.synthesize("Привет", play=False)

# Save to WAV file
wav = retro_ru_tts.pcm_to_wav(pcm)
with open("output.wav", "wb") as f:
    f.write(wav)

API

synthesize(text, ...)

retro_ru_tts.synthesize(
    "Привет, мир!",

    # Voice parameters
    speech_rate=100,     # speech rate (20–500)
    voice_pitch=100,     # voice pitch (50–300)
    intonation=100,      # expressiveness (0–140)

    # Gap factors (pause duration between clauses, default 100)
    general_gap_factor=100,
    comma_gap_factor=100,
    dot_gap_factor=100,
    semicolon_gap_factor=100,
    colon_gap_factor=100,
    question_gap_factor=100,
    exclamation_gap_factor=100,
    intonational_gap_factor=100,

    # Control flags (bitmask)
    flags=3,             # default: DEC_SEP_POINT | DEC_SEP_COMMA

    # Behaviour
    wave_buffer_size=8192,  # internal buffer (256–1048576)
    play=True,              # play through speakers
    normalize=True,         # text normalization (see below)
)

Returns: bytes — raw signed 8-bit PCM audio at 10 kHz, mono.

play(text, ...)

Shortcut for synthesize(text, play=True). Same parameters (except play).

pcm_to_wav(pcm_bytes)

Wraps raw signed 8-bit PCM into a WAV container.

Returns: bytes — complete WAV file (8-bit, 10 kHz, mono).

Flags

The flags parameter is a bitmask controlling decimal separation and voice:

Flag Value Description
DEC_SEP_POINT 1 Treat . as decimal separator (e.g., 3.14)
DEC_SEP_COMMA 2 Treat , as decimal separator (e.g., 3,14)
USE_ALTERNATIVE_VOICE 4 Use alternative (female) voice
USE_LEGACY_RATE_ALGO 8 Use legacy linear interpolation rate algorithm instead of adaptive crossfade

Default value is 3 (DEC_SEP_POINT \| DEC_SEP_COMMA), which means both . and , are accepted as decimal separators.

To use the female voice without decimal comma: flags=5 (DEC_SEP_POINT \| USE_ALTERNATIVE_VOICE).

Text normalization

By default the input text is normalized before being fed to the synthesizer. This converts numbers to words, formats dates and times, expands abbreviations, spells out uppercase acronyms letter by letter, transliterates common English words, and cleans up punctuation.

If ru-normalizr is installed (pip install retro-ru-tts[normalize]), it is used for normalization. Otherwise, a built-in normalizer handles the most common cases:

Feature Example Output
Stress marks ко́фе кофе
Numbers 1234567 один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь
Dates 15.03.2024 пятнадцатое марта две тысячи двадцать четыре года
Time 14:30 четырнадцать тридцать
Units 5 кг, 100 мл пять килограмм, сто миллилитров
Temperature -5 °C минус пять градусов по Цельсию
Currency 300 руб., 50$ триста рублей, пятьдесят долларов
Symbols 100%, №5 сто процентов, номер пять
Abbreviations т.д., т.е., напр. так далее, то есть, например
Acronyms TTS, РФ, USB тэ тэ эс, эр эф, у эс бэ
Ordinals 1-й, 3-я первый, третья
Decimals 3.14 три запятая одна четыре
Phone +7 495 123 45 67 восемь четыре девять пять один два три четыре пять шесть семь
English hello, world, ok хэллоу, уорлд, окей
URLs/emails http://example.com ссылка / электронный адрес
# Skip normalization for raw PCM output
retro_ru_tts.synthesize("Версия 3.2", normalize=False)

PCM format

Property Value
Format Signed 8-bit PCM
Sample rate 10000 Hz
Channels Mono (1)

Build from source

Prerequisites

  • C compiler (GCC, Clang, MSVC)
  • Python 3.7+ with setuptools
  • Make (Linux) or build tools (Windows)

Steps

git clone https://github.com/Blue-Kod/retro-ru-tts.git
cd retro-ru-tts

# Development install (editable)
pip install -e .

# Build distribution package
pip install build
python -m build

PCM output data

The engine produces raw signed 8-bit PCM at a fixed 10 kHz sample rate, mono. This is a deliberately minimal, low-bandwidth format suitable for embedded systems, screen readers, and retro computing applications.

License

MIT. This wrapper is distributed under the same license as the original ru_tts by Igor Poretsky. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

retro_ru_tts-1.0.5.tar.gz (82.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

retro_ru_tts-1.0.5-cp314-cp314-win_amd64.whl (139.2 kB view details)

Uploaded CPython 3.14Windows x86-64

retro_ru_tts-1.0.5-cp313-cp313-win_amd64.whl (138.1 kB view details)

Uploaded CPython 3.13Windows x86-64

retro_ru_tts-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.5-cp313-cp313-macosx_11_0_arm64.whl (137.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

retro_ru_tts-1.0.5-cp313-cp313-macosx_10_13_x86_64.whl (137.2 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

retro_ru_tts-1.0.5-cp312-cp312-win_amd64.whl (138.1 kB view details)

Uploaded CPython 3.12Windows x86-64

retro_ru_tts-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.5-cp312-cp312-macosx_11_0_arm64.whl (137.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

retro_ru_tts-1.0.5-cp312-cp312-macosx_10_13_x86_64.whl (137.2 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

retro_ru_tts-1.0.5-cp311-cp311-win_amd64.whl (138.1 kB view details)

Uploaded CPython 3.11Windows x86-64

retro_ru_tts-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (187.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.5-cp311-cp311-macosx_11_0_arm64.whl (137.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

retro_ru_tts-1.0.5-cp311-cp311-macosx_10_9_x86_64.whl (137.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file retro_ru_tts-1.0.5.tar.gz.

File metadata

  • Download URL: retro_ru_tts-1.0.5.tar.gz
  • Upload date:
  • Size: 82.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for retro_ru_tts-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f3583537b9a802326ccf581b360bbf025a89b8a8696b08ce4150116fe3405ba3
MD5 43db8c0b63f8294edabc599c1974548d
BLAKE2b-256 15967bf31bb25f39d280222a805af980d32c002f7d94dab5add5cc3bd9950cb5

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 9075a81c50ae6f1e297bd200ce2aae2ca0971863a3a25ff8f29e73929a211eb2
MD5 c76f2de7f865db2a37bb88420eb5eb42
BLAKE2b-256 7da095c8df8ed476d3ef532f52fe3e0b3b6bc4c7fbe6cf0d19b489d586f0f031

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7aff3f7ea1aff62e165b7dc33c8ad5de0da8a632670f011a868b34373a6bfb24
MD5 d3e6134d9dad2d74879a9470d7a33bd0
BLAKE2b-256 df93efd20afefc2fd3b05941d56674225f40f2bf1571299bbd1e5dc8d3864ffc

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8aff0b87887a68297ca991b1776bd209879e3477f9ac047f452152782c4d33af
MD5 36b029f5a72bb5c9c178ab4e60bfc0b5
BLAKE2b-256 e2e982d7dfc437d2b71b01d673624046e76d35cb31e69425282c1604417c3e73

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d6d7cceee09f1d539eaf14ca7f86219a0772809638717272b49b0cce854beb4
MD5 9b9a50066feab3a031be482d197226d5
BLAKE2b-256 ec8247119d14c24ffbf9b6374b59cfa350d167a45c437bbd5c283757ad43dc57

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f7e3e946eb3b1e0253d4fc335598c4c5f0eb933b388595b135bb073461d96cbc
MD5 57a9844474c070edccf0de8da5835640
BLAKE2b-256 2fb4bfc61c0c456d07e9599df3df03c8ab34cc9fa54ec070ff29ad70a18f62cd

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 965702db2098e147e1aa15f46a40481dc74068402f4cdaaba748014406df8d98
MD5 4788e942b1b3973a80fd308f77d1ee75
BLAKE2b-256 bda08fd9cea7282c165112f0855809e742ffa66a666b475cd5a0ddd21fee055d

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e37cd82e282ba23ae476844e44535b5157e670558602db7a37ca038f6b5ee0b5
MD5 7cd04b7ab3f7186fd4a5e2b9d574341d
BLAKE2b-256 4e961624d99feeac748d7ca92a808e86a63c0694f11c0ead416c47be70c68a00

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dd5c8b28ac4c2795b29609ba61ce6f2afd2fcb762d8bacaa71eba496db028e0
MD5 d55942db4f72f86f3ec1e310435dbbc4
BLAKE2b-256 162b0362aadb81e0a5d0848b87be70a2c950ef929069a880528ad327e437a7e0

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7903dab457540c3ba5ee44d54b5428bbba31f165ba6d041207d3adb2ac82f8ad
MD5 ff4edc8f44dbe78bb15578adfdf6b457
BLAKE2b-256 b249fa560f7129e88b35db3ae017a89d43f77b74451d376c2740e9ca90e45a34

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 84226c0ecc06643ff6f5b3038d61561c538a2862ed97843157d0c4bc32ea3c24
MD5 6b5fa2a2bb11710232b3e225e5d4e688
BLAKE2b-256 f3564f9bede1bdd7b61fed0ed026e3798d67e68e123068bf0e9db3bcb58a8932

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3fb187aaa97861b5bd9c68ce3b2a809116d90815281660327c63305685d078fc
MD5 1dd86cec960a84e1d48b13ce73629381
BLAKE2b-256 ba2af60f62210612e3dc73db0de3082b7786051545937e96b6d2da74fd3f7e17

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0348326af1fb35f3b80436dec77e6426d5a978bdb7c7737dfde841d079e3c9f
MD5 8a10e170d272ffedffc28d60a209d796
BLAKE2b-256 dae1c3f48e5c47bb63b7c295dafc251582a843aa2b85289f795ec02d5240b624

See more details on using hashes here.

File details

Details for the file retro_ru_tts-1.0.5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for retro_ru_tts-1.0.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a202145d74de50e761c537d7deff337125d3684df417b00d2f2ae07faca2ee5c
MD5 6d28a3872956b646c594496b1325c35e
BLAKE2b-256 dcc6aaf20150ec768ea2350f49785623754c7d33524fa1c6c3a6f493474b7f87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page