license: cc-by-nc-4.0
tags:
- tts
- gpt2
- vae
pipeline_tag: text-to-speech
Malayalam Text-to-Speech
This repository contains the Malayalam (mal) language text-to-speech (TTS) model checkpoint.
Model Details
Sura (Stochastic Unified Representation for Adversarial learning) is an advanced speech synthesis model that generates speech waveforms conditioned on input text sequences. It is based on a conditional variational autoencoder (VAE) architecture, consisting of a posterior encoder, a decoder, and a conditional prior.
The model's text encoder is built on GPT-2, while the decoder is a VAE with 124M parameters. The flow-based module predicts spectrogram-based acoustic features, which is composed of the GPT-2-based encoder and cascaded dense layers. The spectrogram is then transformed into a speech waveform using a stack of transposed convolutional layers. To capture the one-to-many nature of TTS, where the same text can be spoken in multiple ways, the model also includes a stochastic duration predictor, allowing for varied speech rhythms from the same text input.
Sura is trained end-to-end using a combination of losses from the variational lower bound and adversarial training techniques. During inference, the text encodings are up-sampled based on the predicted durations, and subsequently mapped into the waveform via the flow module and the VAE decoder. Due to the stochastic nature of the duration predictor, the model is non-deterministic and requires a fixed seed to produce identical speech outputs.
Usage
pip install --upgrade transformers accelerate
Then, run inference with the following code-snippet:
from transformers import VitsModel, AutoTokenizer
import torch
model = VitsModel.from_pretrained("aoxo/gpt2-vae-tts-mal")
tokenizer = AutoTokenizer.from_pretrained("facebook/gpt2-vae-tts-mal")
text = "കള്ളാ കടയാടി മോനെ"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
output = model(**inputs).waveform
The resulting waveform can be saved as a .wav
file:
import scipy
scipy.io.wavfile.write("kadayadi_mone.wav", rate=model.config.sampling_rate, data=output)
Or displayed in a Jupyter Notebook / Google Colab:
from IPython.display import Audio
Audio(output, rate=model.config.sampling_rate)
License
The model is licensed as CC-BY-NC 4.0.