Silero Models: pre-trained enterprise-grade STT / TTS models and benchmarks.
Enterprise-grade STT made refreshingly simple (seriously, see benchmarks).
We provide quality comparable to Google's STT (and sometimes even better) and we are not Google.
As a bonus:
No Kaldi;
No compilation;
No 20-step instructions;
Also we have published TTS models that satisfy the following criteria:
One-line usage;
A large library of voices;
A fully end-to-end pipeline;
Natural-sounding speech;
No GPU or training required;
Minimalism and lack of dependencies;
Faster than real-time on one CPU thread (!!!);
Support for 16kHz and 8kHz out of the box;
Also we have published a model for text repunctuation and recapitalization that:
Inserts capital letters and basic punctuation marks, e.g., dots, commas, hyphens, question marks, exclamation points, and dashes (for Russian);
Works for 4 languages (Russian, English, German, and Spanish) and can be extended;
Domain-agnostic by design and not based on any hard-coded rules;
Has non-trivial metrics and succeeds in the task of improving text readability;
Installation and Basics
You can basically use our models in 3 flavours:
Via PyTorch Hub: torch.hub.load();
Via pip: pip install silero and then import silero;
Via caching the required models and utils manually and modifying if necessary;
Models are downloaded on demand both by pip and PyTorch Hub. If you need caching, do it manually or via invoking a necessary model once (it will be downloaded to a cache folder). Please see these docs for more information.
PyTorch Hub and pip package are based on the same code. All of the torch.hub.load examples can be used with the pip package via this basic change:
python3
1# before
2torch.hub.load(repo_or_dir='snakers4/silero-models',
3 model='silero_stt', # or silero_tts or silero_te
4 **kwargs)
56# after
7from silero import silero_stt, silero_tts, silero_te
8silero_stt(**kwargs)
Speech-To-Text
All of the provided models are listed in the models.yml file.
Any metadata and newer versions will be added there.
torch, 1.8+ (used to clone the repo in TensorFlow and ONNX examples), breaking changes for versions older than 1.6
torchaudio, latest version bound to PyTorch should just work
omegaconf, latest should just work
Additional dependencies for ONNX examples:
onnx, latest should just work
onnxruntime, latest should just work
Additional for TensorFlow examples:
tensorflow, latest should just work
tensorflow_hub, latest should just work
Please see the provided Colab for details for each example below. All examples are maintained to work with the latest major packaged versions of the installed libraries.
1import torch
2import zipfile
3import torchaudio
4from glob import glob
56device = torch.device('cpu')# gpu also works, but our models are fast enough for CPU7model, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models',8 model='silero_stt',9 language='en',# also available 'de', 'es'10 device=device)11(read_batch, split_into_batches,12 read_audio, prepare_model_input)= utils # see function signature for details1314# download a single file in any format compatible with TorchAudio15torch.hub.download_url_to_file('https://opus-codec.org/static/examples/samples/speech_orig.wav',16 dst ='speech_orig.wav', progress=True)17test_files = glob('speech_orig.wav')18batches = split_into_batches(test_files, batch_size=10)19input= prepare_model_input(read_batch(batches[0]),20 device=device)2122output = model(input)23for example in output:24print(decoder(example.cpu()))
1import os
2import torch
3import subprocess
4import tensorflow as tf
5import tensorflow_hub as tf_hub
6from omegaconf import OmegaConf
78language ='en'# also available 'de', 'es'910# load provided utils using torch.hub for brevity11_, decoder, utils = torch.hub.load(repo_or_dir='snakers4/silero-models', model='silero_stt', language=language)12(read_batch, split_into_batches,13 read_audio, prepare_model_input)= utils
1415# see available models16torch.hub.download_url_to_file('https://raw.githubusercontent.com/snakers4/silero-models/master/models.yml','models.yml')17models = OmegaConf.load('models.yml')18available_languages =list(models.stt_models.keys())19assert language in available_languages
2021# load the actual tf model22torch.hub.download_url_to_file(models.stt_models.en.latest.tf,'tf_model.tar.gz')23subprocess.run('rm -rf tf_model && mkdir tf_model && tar xzfv tf_model.tar.gz -C tf_model', shell=True, check=True)24tf_model = tf.saved_model.load('tf_model')2526# download a single file in any format compatible with TorchAudio27torch.hub.download_url_to_file('https://opus-codec.org/static/examples/samples/speech_orig.wav', dst ='speech_orig.wav', progress=True)28test_files =['speech_orig.wav']29batches = split_into_batches(test_files, batch_size=10)30input= prepare_model_input(read_batch(batches[0]))3132# tf inference33res = tf_model.signatures["serving_default"](tf.constant(input.numpy()))['output_0']34print(decoder(torch.Tensor(res.numpy())[0]))
Text-To-Speech
Models and Speakers
All of the provided models are listed in the models.yml file. Any metadata and newer versions will be added there.
V4
V4 models support SSML. Also see Colab examples for main SSML tag usage.
Denoise models attempt to reduce background noise along with various artefacts such as reverb, clipping, high/lowpass filters etc., while trying to preserve and/or enhance speech. They also attempt to enhance audio quality and increase sampling rate of the input up to 48kHz.
Models
All of the provided models are listed in the models.yml file.