Skip to main content

Script over the official Silero so that it can be conveniently and quickly used from the code or from the console

Project description

Silero TTS

README is available in the following languages:

EN RU

Silero TTS is a Python library that provides an easy way to synthesize speech from text using various Silero TTS models, languages, and speakers. It can be used as a standalone script or integrated into your own Python projects.

Features

  • Support for multiple languages and models
  • Automatic downloading of the latest model configuration file
  • Text preprocessing and transliteration
  • Batch processing of text files
  • Detailed logging with loguru
  • Progress tracking with tqdm
  • Customizable options for sample rate, device, and more
  • Can be used as a standalone script or integrated into Python code

Installation

Auto ( Recomended )

pip install silero-tts

Manualy

  1. Clone the repository:

    git clone https://github.com/daswer123/silero-tts-enhanced
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Usage

As a Standalone Script

You can use Silero TTS as a standalone script to synthesize speech from text files or directories containing text files.

python -m silero_tts [options]

Options

  • --list-models: List available models
  • --list-speakers: List available speakers for a model
  • --language LANGUAGE: Specify the language code (required)
  • --model MODEL: Specify the model ID (default: latest version for the language)
  • --speaker SPEAKER: Specify the speaker name (default: first available speaker for the model)
  • --sample-rate SAMPLE_RATE: Specify the sample rate (default: 48000)
  • --device DEVICE: Specify the device to use (default: cpu)
  • --text TEXT: Specify the text to synthesize
  • --input-file INPUT_FILE: Specify the input text file to synthesize
  • --input-dir INPUT_DIR: Specify the input directory with text files to synthesize
  • --output-file OUTPUT_FILE: Specify the output audio file (default: output.wav)
  • --output-dir OUTPUT_DIR: Specify the output directory for synthesized audio files (default: output)

Examples

  1. Synthesize speech from a text:

    python silero_tts.py --language ru --text "Привет, мир!"
    
  2. Synthesize speech from a text file:

    python silero_tts.py --language en --input-file input.txt --output-file output.wav
    
  3. Synthesize speech from multiple text files in a directory:

    python silero_tts.py --language es --input-dir texts --output-dir audio
    

As a Python Library

You can also integrate Silero TTS into your own Python projects by importing the SileroTTS class and using its methods.

from silero_tts.silero_tts import SileroTTS

# Initialize the TTS object
tts = SileroTTS(model_id='v3_en', language='en', speaker='en_3', sample_rate=48000, device='cpu')

# Synthesize speech from text
text = "Hello, world!"
tts.tts(text, 'output.wav')

# Synthesize speech from a text file
# tts.from_file('input.txt', 'output.wav')

# Get available models
models = SileroTTS.get_available_models()
print(models)

# Get available speakers for a model
speakers = tts.get_available_speakers()
print(speakers)

CLI Features

The Silero TTS CLI provides the following features:

  • Language Support: Specify the language code using the --language flag to synthesize speech in the desired language.
  • Model Selection: Choose a specific model using the --model flag or let the CLI automatically select the latest model for the specified language.
  • Speaker Selection: Select a speaker using the --speaker flag or use the default speaker for the chosen model.
  • Sample Rate: Customize the sample rate of the synthesized speech using the --sample-rate flag.
  • Device: Specify the device (CPU or GPU) to use for synthesis using the --device flag.
  • Text Input: Provide the text to synthesize directly using the --text flag or specify an input text file using the --input-file flag.
  • Batch Processing: Process multiple text files in a directory using the --input-dir flag.
  • Output: Specify the output audio file using the --output-file flag or the output directory for batch processing using the --output-dir flag.
  • Model Listing: List all available models using the --list-models flag.
  • Speaker Listing: List all available speakers for a specific model using the --list-speakers flag.

Supported Languages

  • Russian (ru)
  • English (en)
  • German (de)
  • Spanish (es)
  • French (fr)
  • Bashkir (ba)
  • Kalmyk (xal)
  • Tatar (tt)
  • Uzbek (uz)
  • Ukrainian (ua)
  • Indic (indic)
  • Cyrillic (cyrillic)

License

This project is licensed under the MIT License.

Acknowledgements

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

silero_tts-0.0.3.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

silero_tts-0.0.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file silero_tts-0.0.3.tar.gz.

File metadata

  • Download URL: silero_tts-0.0.3.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for silero_tts-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ca7489d7cb25aad7fd550603352ec0902a0d87589ca1e3844663aab63b5ec14d
MD5 afa19de659ad835eb0f37b482fe6ada9
BLAKE2b-256 9b4f814bb682d1eed0f5b09a02ff0f533867422b57fae16a116c456661629648

See more details on using hashes here.

File details

Details for the file silero_tts-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: silero_tts-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for silero_tts-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84a3a532903a3b1bd9e3487d76e5c24b2aee4dd183c4c2c57526b485c3059ed2
MD5 baf00f6a4c869ee32fe3ef325f9ec209
BLAKE2b-256 6cb2683814cf42214f089a18cb9cfc02a2a3f33d3b818112b72c73c6c4215533

See more details on using hashes here.

Supported by

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