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.4.tar.gz (81.6 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.4-cp314-cp314-win_amd64.whl (138.7 kB view details)

Uploaded CPython 3.14Windows x86-64

retro_ru_tts-1.0.4-cp313-cp313-win_amd64.whl (137.7 kB view details)

Uploaded CPython 3.13Windows x86-64

retro_ru_tts-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (187.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.4-cp313-cp313-macosx_11_0_arm64.whl (137.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

retro_ru_tts-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl (136.6 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

retro_ru_tts-1.0.4-cp312-cp312-win_amd64.whl (137.7 kB view details)

Uploaded CPython 3.12Windows x86-64

retro_ru_tts-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (187.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.4-cp312-cp312-macosx_11_0_arm64.whl (137.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

retro_ru_tts-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl (136.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

retro_ru_tts-1.0.4-cp311-cp311-win_amd64.whl (137.7 kB view details)

Uploaded CPython 3.11Windows x86-64

retro_ru_tts-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (187.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

retro_ru_tts-1.0.4-cp311-cp311-macosx_11_0_arm64.whl (137.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

retro_ru_tts-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl (136.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: retro_ru_tts-1.0.4.tar.gz
  • Upload date:
  • Size: 81.6 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.4.tar.gz
Algorithm Hash digest
SHA256 48232131b73c8c56049232f4b7e1649117957671a5e442fd893e462c068557a5
MD5 964a852afc2dda036af067650e961212
BLAKE2b-256 795b2834f274d4ec1cecd52b3af1e224bb118da294da3dfbb2aad7a5728e42e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 efb79c1184ed12bd9841ab19a502e15960d37725e6863a0052dab52e39959a46
MD5 47acf714529fa22ccaa98854b881c7d4
BLAKE2b-256 2acb6b463793c10e9acc4e82a18908221ab2421920dd3ff6a96a3a2d604ffb31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a2d4c265547a8678df68655feb1ceb901b15672371ca5b1eb3bc718b72dde61f
MD5 b1d66fb5e563e08e225e5ba22d1a72f9
BLAKE2b-256 be7e31d841664b93ea7e611cecd254c65901d31056ddcba7b63395a41a4f2f05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 175ef244f3bd07440b4149dd8cef376cb721c2b56512802794bb53a602d7a445
MD5 925e07101e969a27779add4ace9aedb9
BLAKE2b-256 6d0adbc43bc2551299dc20bc9e1b0f5d821c2adb4d644d405ec75c26216349f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdae56c883420b81741369015752a903ac25ec514a94564f6f1997456cc124a2
MD5 42f3f9a2ab688e93fcbd99a2b7bdef66
BLAKE2b-256 e6b84b36fdfa960feb7963c16c70cb6a52fe3296d43e9a46eda301a5d9b8e329

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5565f36ab34ae344c16f3cde01b96bd230bf90823abe487c82fc8ef2ff4d30b9
MD5 f354d64637ebedfbe8d8a9cc3c956122
BLAKE2b-256 34b31829acabb670f53979305606282fedf77afbec5b02e0ddc1e04784e4922a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8185cda22c2d7f365f9ace36e899e62aac6b32b6b5e7138d55396e495826ca62
MD5 be7f69815f65efa9955bec797ad829d7
BLAKE2b-256 b8b743c4cd2a7d2706a0f8e9435b3ecbdd531cd17ed8cac38b34f1ef7c1b7963

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0dc63afa66a353ca8e11b2451feabec6e21fcd762b1029aa7ad5d837e1db1cac
MD5 1b8766e8a4c0cbb5fc466f7f46e94177
BLAKE2b-256 45bc21dad5f5ebf8d39579560fc01caf90480d481cd52a1dfed602cba2b4a3dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7264af15f3d74334b2eb17a7f64edb40a512041dbbf1ce35b8854b1888853de4
MD5 3880c0f0eadcf30519846e36780d7660
BLAKE2b-256 e51d99462cadd4b1f2df7ff5eaae63b21af1f9a753d86bfd0431d126071b7d32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b3dab770cf01ec2e28bf10153b766e4e750c07178d4228efd77576c0f28c0a0e
MD5 016d85c196924dd60ef6bd212f28c8ea
BLAKE2b-256 eed2f6d2101e2c2bada4ce071612d181f5dbadc082332f87bb2e8cd4eceed3b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5b6b6a3636da16cd2f97e5827e0d1efe22f2c51d4b3e21655f225d55ec03e13e
MD5 b82d3143626ef8ef759acff0a88a5563
BLAKE2b-256 782200b7055ce50cc47307798bf9c3eb895bd52a67b0b52b59e6cbb1cc597fb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92bb7ca2d95424b604bbeef1a648205e7505543c482d70cb6e98a7b98d3326ba
MD5 e33b0b051aee12d46feb830042dba627
BLAKE2b-256 05c24e61dc4ce8a935263508070cfddedd5480e7158780d0c22a0ea0a393266f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7f65365ae139fdab8d814f90410128b2d2f584ba0ddcd8e72f59d8ff4a533424
MD5 f36d1411cac32b5908780fbbac4431e0
BLAKE2b-256 04d402013319d22d6fec582e420b2fd913e7d4440b72dbbd95be07e668fa121b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for retro_ru_tts-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d627fbd607c2d3d516e4f3b813f986a4c9cb2d3c970397db836919a88f8cc86f
MD5 2cdc6d7f452861ecba97dc71f9270164
BLAKE2b-256 d2ddf5bfe273f0102b54c75a06f53bfd669498ec9efe1a3d7f0fc961bbe6fbfb

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