Project · AI & ML
Streaming TTS & Voice Conversion
Typing a sentence and hearing it in someone else's voice: Meta's MMS text-to-speech chained with RVC voice conversion, streamed chunk by chunk, then a look at what that makes possible.
- Ref.
- 01.05
- Period
- Sep 2023
- Status
- Completed
- Organization
- Personal
- Contributors
- Axel COLMANT
- Stack
- Python
- PyTorch
- Hugging Face
- MMS
- RVC
Key points
- Text read by MMS, Meta's text-to-speech for 1,100+ languages, then turned into another voice with RVC.
- Streamed chunk by chunk: playback starts after the first chunk, while the next ones are generated.
- A side project from the 2023 wave of AI covers, made for fun.
- Looking back: deepfakes, dubbing and the right to one's own voice.
Context
In 2023, AI covers were everywhere: songs “sung” by artists who never recorded them, made with open-source voice conversion models. In France, one with Angèle's voice went viral.
I wanted to see how far these open tools had come, and whether I could chain them: type a sentence, and hear it spoken in a chosen voice. It was a project for fun, done in a few evenings. The code was not versioned and is lost; what is left is the pipeline and an audio sample.
The pipeline
Two models in a row (Fig. 1): a text-to-speech model turns the text into a neutral synthetic voice, then a voice conversion model changes its timbre into the target voice, keeping the words and the intonation.
Text to speech: MMS
MMS (Massively Multilingual Speech) is a Meta project from 2023 that covers more than 1,100 languages. Its text-to-speech models are VITS models, one per language, published on Hugging Face: they take text and output 16 kHz audio, in a single synthetic voice per language. Audio 1 is a raw MMS output, before any conversion.
Voice conversion: RVC
RVC (Retrieval-based Voice Conversion) changes who seems to be speaking, not what is said. It reads the input with HuBERT, a speech model that describes the content of each slice of audio while mostly ignoring the speaker. It then swaps these descriptions for the closest ones found in recordings of the target voice (the index, the “retrieval” part), and a decoder trained on that voice rebuilds the audio, following the pitch of the input.
Training it takes a few minutes of clean recordings of the target voice and a consumer GPU. The output of my pipeline is not on this page on purpose: it is a voice that is not mine, used without its owner's consent, which is exactly the problem below.
Streaming
Run one after the other on a whole paragraph, the two models keep you waiting: nothing plays until the last word has been converted. So I streamed it, the way a video player starts before the whole file is downloaded.
Measure first. I timed MMS + RVC on my machine and kept their average speed as a ratio : computing time divided by the duration of the audio produced. Below 1, the pipeline computes faster than it talks.
Then cut and overlap. The text is cut into chunks. Each chunk goes through MMS then RVC and joins a queue, and playback starts as soon as the first one is ready, while the next ones are being generated (Fig. 2). The wait before the first sound now depends on one chunk, not on the length of the text.
If is above 1, playback catches up with generation and stalls. The average speed tells how much to wait: with a steady speed, for a text that lasts seconds, delaying playback by
seconds, on top of the first chunk, is enough for playback never to run dry (Eq. 1).
Looking back
At the time, it was a fun technical toy. Seen from today, the main lesson is how little it takes: free tools, a gaming GPU and a few minutes of someone's voice are enough to make them say anything.
Deepfakes. A cloned voice can fake a phone call from a relative asking for money, or a statement a public figure never made. Audio is harder to doubt than an image: we are used to trusting a voice we know.
Dubbing and voice acting. A voice actor's recordings can be used to train a model that then replaces them. Their performance is protected by performers' rights, but the voice itself is not a work: in France it is treated as an attribute of the person, like their image, rather than as intellectual property.
References
- [1]Pratap et al. (Meta AI) (2023). Scaling Speech Technology to 1,000+ Languages
- [2]Kim, Kong, Son (2021). Conditional Variational Autoencoder with Adversarial Learning for End-to-End Text-to-Speech (VITS). ICML
- [3]Hsu et al. (2021). HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units
- [4]RVC-Project. Retrieval-based Voice Conversion WebUI