{"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.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install torch torchaudio silero soundfile"],"cli":null},"imports":["import torch","import torchaudio","from silero.utils import save_audio","from silero.utils import read_audio"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}