{"id":10225,"library":"silero","title":"Silero Models","description":"Silero Models provides a collection of pre-trained enterprise-grade Text-to-Speech (TTS) models primarily focused on Russian and CIS languages, as well as speech-to-text models. It leverages PyTorch for model inference, offering high-quality and fast speech generation. The library is actively maintained with frequent updates, currently at version 0.5.5, with a focus on expanding language support and model quality.","status":"active","version":"0.5.5","language":"en","source_language":"en","source_url":"https://github.com/snakers4/silero-models","tags":["speech-synthesis","tts","ai","deep-learning","audio","pytorch","nlp"],"install":[{"cmd":"pip install torch torchaudio silero soundfile","lang":"bash","label":"Recommended installation with core dependencies"}],"dependencies":[{"reason":"Core deep learning framework for model inference. Essential for all model operations.","package":"torch","optional":true},{"reason":"Audio processing library required for loading, saving, and manipulating audio data. Essential for I/O operations and some model components.","package":"torchaudio","optional":true},{"reason":"Required by torchaudio for reading and writing various audio file formats.","package":"soundfile","optional":true}],"imports":[{"symbol":"torch","correct":"import torch"},{"symbol":"torchaudio","correct":"import torchaudio"},{"symbol":"silero.utils.save_audio","correct":"from silero.utils import save_audio"},{"symbol":"silero.utils.read_audio","correct":"from silero.utils import read_audio"}],"quickstart":{"code":"import torch\nimport torchaudio\n\n# Ensure PyTorch is available and get device\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n\n# --- TTS Quickstart ---\n# Define model parameters\nmodel_id = 'v5_ru'\nlanguage = 'ru'\nspeaker = 'baya'\nput_accent = True\nput_yo = True\nsample_rate = 48000 # or 24000, 16000\ntext = 'В недрах тундры выдры в гетрах тырят в вёдра ядра кедров.'\n\ntry:\n    # Load the Silero TTS model from torch.hub\n    model, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',\n                              model='silero_tts',\n                              language=language,\n                              speaker=model_id,\n                              put_accent=put_accent,\n                              put_yo=put_yo)\n    model.to(device)\n\n    # Synthesize audio\n    audio_tensor = model(text=text, speaker=speaker, sample_rate=sample_rate)\n    \n    # Example of saving audio (requires 'soundfile')\n    # from silero.utils import save_audio\n    # output_path = 'output_audio.wav'\n    # save_audio(audio_tensor.cpu(), output_path, sample_rate)\n    # print(f'Audio saved to {output_path}')\n    \n    print(f\"Successfully synthesized audio. Tensor shape: {audio_tensor.shape}, Sample Rate: {sample_rate}\")\nexcept Exception as e:\n    print(f\"An error occurred during TTS synthesis: {e}\")\n    print(\"Please ensure PyTorch, TorchAudio, and potentially SoundFile are installed.\")","lang":"python","description":"This quickstart demonstrates how to load a pre-trained Silero TTS model using `torch.hub.load` and synthesize speech from text. It uses the 'v5_ru' Russian model with a specific speaker. Make sure `torch`, `torchaudio`, and `soundfile` are installed as they are crucial prerequisites, even if not direct dependencies of the `silero` PyPI package itself."},"warnings":[{"fix":"Migrate to using `v5_ru` or `v5_cis_*` model identifiers. Refer to the official GitHub repository's `models.yml` or quickstart for current supported model IDs and languages.","message":"Silero v5.0 and later versions (e.g., v5.2) deprecated and removed legacy models (v1 and v2) and tools. Attempting to load these older models will result in errors.","severity":"breaking","affected_versions":">=5.0"},{"fix":"Always install `torchaudio` explicitly alongside `silero` using `pip install torchaudio` or include it in your requirements file.","message":"As of v5.1, `torchaudio` was removed as a direct dependency of the `silero` pip package. While `silero` installs without it, `torchaudio` is still essential for most functionalities (e.g., audio I/O, many model operations).","severity":"breaking","affected_versions":">=5.1"},{"fix":"Always install all necessary dependencies explicitly: `pip install torch torchaudio silero soundfile`.","message":"The core dependencies `torch`, `torchaudio`, and `soundfile` are not always automatically installed by `pip install silero`. Missing these will lead to `ModuleNotFoundError` or `RuntimeError` during model loading or inference.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review the GNU AGPL 3.0 license agreement to ensure compliance with its terms, especially if using Silero Models in a commercial or distribution context.","message":"The license for Silero Models changed to GNU AGPL 3.0 in v5.4. Previous versions used CC BY-NC 4.0. Users should be aware of the implications of the AGPL-3.0 license for commercial or proprietary use.","severity":"gotcha","affected_versions":">=5.4"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install `torchaudio`: `pip install torchaudio`.","cause":"The `torchaudio` library, which is critical for Silero's audio processing, is not installed.","error":"ModuleNotFoundError: No module named 'torchaudio'"},{"fix":"Check the available languages and model IDs in the official Silero Models repository's `models.yml` file or the quickstart guide. Ensure you are using a currently supported model, especially after v5.0 breaking changes.","cause":"The specified language or model ID in `torch.hub.load` is either incorrect or not supported by the current Silero model version.","error":"RuntimeError: Requested model is not available for language 'xx'. Available languages: [...]"},{"fix":"Ensure all tensors, including the model itself, input text embeddings (if manually processed), and any other relevant data, are moved to the same device (e.g., `model.to(device)` and `input_tensor.to(device)`).","cause":"A common PyTorch error indicating that tensors involved in an operation are not on the same computational device (e.g., one on GPU, one on CPU).","error":"RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!"}]}