🚀 Text to Speech Russian free multispeaker model
This is a multiple speakers text-to-speech model for the Russian language, which can directly process plain text with punctuation and doesn't need text-to-phoneme conversion.
🚀 Quick Start
This is a multiple speakers text-to-speech model for the Russian language. It works on plain text with punctuation separation, and does not require prior conversion of the text into phonemes.
The model with multiple speakers has two voices: 0 - woman, 1 - man.
The size of the model is only 15.1 million parameters.
The text accepts lowercase.
For better generation quality, we recommend putting accents in the text before the vowel letters.
We recommend using the "ruaccent" library for accentuation.
✨ Features
- Multiple Speakers: Offers two voices (woman and man) for text-to-speech conversion.
- Plain Text Support: Works directly on plain text with punctuation, eliminating the need for text-to-phoneme conversion.
- Small Model Size: Only has 15.1 million parameters.
- Accentuation Support: Recommends using the "ruaccent" library for better generation quality.
📦 Installation
To install "ruaccent", use:
pip install -y ruaccent
💻 Usage Examples
Basic Usage
For test inference use Spaces:
https://huggingface.co/spaces/utrobinmv/tts_ru_free_hf_vits_low_multispeaker
Advanced Usage
Using PyTorch
from transformers import VitsModel, AutoTokenizer, set_seed
import torch
import scipy
from ruaccent import RUAccent
device = 'cuda'
speaker = 0
set_seed(555)
model_name = "utrobinmv/tts_ru_free_hf_vits_low_multispeaker"
model = VitsModel.from_pretrained(model_name).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_name)
model.eval()
accentizer = RUAccent()
accentizer.load(omograph_model_size='turbo', use_dictionary=True, device=device)
text = """Ночью двадцать третьего июня начал извергаться самый высокий
действующий вулкан в Евразии - Кл+ючевской. Об этом сообщила руководитель
Камчатской группы реагирования на вулканические извержения, ведущий
научный сотрудник Института вулканологии и сейсмологии ДВО РАН Ольга Гирина.
«Зафиксированное ночью не просто свечение, а вершинное эксплозивное
извержение стромболианского типа. Пока такое извержение никому не опасно:
ни населению, ни авиации» пояснила ТАСС госпожа Гирина."""
text = accentizer.process_all(text)
print(text)
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
output = model(**inputs.to(device), speaker_id=speaker).waveform
output = output.detach().cpu().numpy()
scipy.io.wavfile.write("tts_audio.wav", rate=model.config.sampling_rate,
data=output[0])
For displayed in a Jupyter Notebook / Google Colab:
from IPython.display import Audio
Audio(output, rate=model.config.sampling_rate)
Using ONNX
First copy the model.onnx file to the folder "tts_ru_free_hf_vits_low_multispeaker".
import numpy as np
import scipy
import onnxruntime
from ruaccent import RUAccent
from transformers import AutoTokenizer
speaker = 0
model_path = "tts_ru_free_hf_vits_low_multispeaker/model.onnx"
sess_options = onnxruntime.SessionOptions()
model = onnxruntime.InferenceSession(model_path, sess_options=sess_options)
tokenizer = AutoTokenizer.from_pretrained("utrobinmv/tts_ru_free_hf_vits_low_multispeaker")
text = """Ночью двадцать третьего июня начал извергаться самый высокий
действующий вулкан в Евразии - Кл+ючевской. Об этом сообщила руководитель
Камчатской группы реагирования на вулканические извержения, ведущий
научный сотрудник Института вулканологии и сейсмологии ДВО РАН Ольга Гирина.
«Зафиксированное ночью не просто свечение, а вершинное эксплозивное
извержение стромболианского типа. Пока такое извержение никому не опасно:
ни населению, ни авиации» пояснила ТАСС госпожа Гирина."""
accentizer = RUAccent()
accentizer.load(omograph_model_size='turbo', use_dictionary=True)
text = accentizer.process_all(text)
inputs = tokenizer(text, return_tensors="np")
sid = np.array([speaker])
sampling_rate = 16000
output = model.run(
None,
{
"input_ids": inputs['input_ids'],
"attention_mask": inputs['attention_mask'],
"sid": sid,
},
)[0]
scipy.io.wavfile.write("tts_audio.wav", rate=sampling_rate,
data=output[0])
For displayed in a Jupyter Notebook / Google Colab:
from IPython.display import Audio
Audio(output, rate=sampling_rate)
📚 Documentation
Languages covered
Russian (ru_RU)
📄 License
This project is licensed under the Apache-2.0 license.