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 example.com/privet эксэмпэл точка ком слэш привет
Emails user@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.6.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.6-cp314-cp314-win_amd64.whl (139.2 kB view details)

Uploaded CPython 3.14Windows x86-64

retro_ru_tts-1.0.6-cp313-cp313-win_amd64.whl (138.2 kB view details)

Uploaded CPython 3.13Windows x86-64

retro_ru_tts-1.0.6-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.6-cp313-cp313-macosx_11_0_arm64.whl (137.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

retro_ru_tts-1.0.6-cp313-cp313-macosx_10_13_x86_64.whl (137.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

retro_ru_tts-1.0.6-cp312-cp312-win_amd64.whl (138.2 kB view details)

Uploaded CPython 3.12Windows x86-64

retro_ru_tts-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (188.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

retro_ru_tts-1.0.6-cp312-cp312-macosx_10_13_x86_64.whl (137.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

retro_ru_tts-1.0.6-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.6-cp311-cp311-macosx_11_0_arm64.whl (137.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

retro_ru_tts-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl (137.0 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: retro_ru_tts-1.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 d53d8e56fe9bb53cad4b646d491d0419634433fa0c3c6fbdc4a0b24025886c40
MD5 65970a3742b6da8e352c84a58c5e9a79
BLAKE2b-256 dd005365942a02db588a7e22d2ed023e02297afba09998587c0d0742356780e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1eb0eb3108ff58e4a48adbd3eda63774fa6cc3554a9bcf6f10e960a58bdf983d
MD5 dcae3ceec37540967d2d41f51beaff05
BLAKE2b-256 90d6df832a5e048b6c26bf700537e3ec6d97dc90037778f511cebde3988a0db6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 94887015f6059be68745220457b3549af9a1bf1b1cd22efdf5d2d68f959771a0
MD5 1e6e3e539c7d2b03f7f1ec3fa4f672c7
BLAKE2b-256 21c275fa117cb0445e0b08d130e6e6f73eb426e787eee399b4128613acb1c04e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b48f0633f765dd8cd0ddaa7150da2d5112ac3d66191ecdeb1b7f013537423b3
MD5 2c532f3b2768928290fa61c86108a8b1
BLAKE2b-256 5145f9dabb717bc354a1a706f8881f2b1f4fe830ca9695084e63b983549f3af6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8857bf011e18c708ac300467d0e58e9afa748d630dd767722411b88a74b0b9aa
MD5 cb081962a2ffa79e1f5c2019ecf20420
BLAKE2b-256 f34b543d67e1809a4680d86a7e06bb7f598e88b221f69f8171f7320542cc2f8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0108f517748dbc510b0a010ab58b6093b962935043801c0acf612ac624718fed
MD5 bb7a89d62558a1eda4edc76dbb79cbe3
BLAKE2b-256 39da52073561b4dd2d951be1c77f02bf1a4281994b5ab1f10d9eb1c676163b8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6f121fd1fa1c044355560b0319e97040653f0631d1987a1fee1d835e3d55d79e
MD5 f795ae0cd73cb10f446e51d09762112f
BLAKE2b-256 8aea8f80b3dc7c0d798a833fabda50c685915c14e4602706f1caabbec83faeea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab19c092e7760ef633f3a7850cde63a8d375812d04d2e949976356f10b4f466b
MD5 bc511de8a297fd03c40c5a5e58be8872
BLAKE2b-256 8534f4f3c5f0af8869b4159a7dad5ad1a9f0fe8558f9660d39d4bbf0dd4b663e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f66295c74213b4322249f508d715cf7e8d7ebd8801ec8facb339c8c72273e531
MD5 734abd701aed753030b9c76f09e32cfa
BLAKE2b-256 5c98f1c504eced83aca55570d8f0c7020a136acce5932c61f8c496083d60eb69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6733d98a36bedd3f3b784efe9ee3616554645afdb1d41ccfe631f6a2fdc68231
MD5 db848298219b413524db8a5e5e8ae001
BLAKE2b-256 b034706224ec638effb7adc890f48201f0ef6eada8a1a98806d3594d83aa60e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 611489d2d97907aa46b14c7f8b374a3508a898bbf27d24371e44058c713a61ac
MD5 6b39b152be3185409a330fd543811da3
BLAKE2b-256 a960ea4f2deb63eee735eeb73444ba53099b77a776236f92f3c497a3fb3e3593

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 366450d302e1c2500e5ef1e118b905bb890be81ca56c61c35efad31a268de530
MD5 3d1c62fd2e930c3133887a73bffc6b92
BLAKE2b-256 50234755ba1c9cfe8efa93f011c4d92017672b033cf3417091a3c9b63da6dcb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e6de0544d5e0610e6c399e5adf4e273aa024d6eb66dbb6a7a06dc76beccc7976
MD5 e4c69ba204713b38214eddcb72d0d121
BLAKE2b-256 2e7058b53777cc1f8ecb09c8ce807c246a2b0d2b25cc00e76f8f4cff96805c6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 765a427213cf216f7a90a2f20a686ee1f170ac1793a13628df3eb211855df5a5
MD5 14024dd50f42e9138f42ff42ed5ffa5a
BLAKE2b-256 ee8ccb511647a3a77ed861107a7fc1c97935e2a2240885c8dc2b953bc626b266

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