Skip to main content

F5 Quantized so smol

HF: Mode weight

F5 TTS — MLX

This repo is a fork of original f5-tts-mlx implementation but a quantized flow-matching model that is only 223MB in size. The repo is meant to be used as a component of my blog post on low VRAM voice generator

Implementation of F5-TTS, with the MLX framework.

F5 TTS is a non-autoregressive, zero-shot text-to-speech system using a flow-matching mel spectrogram generator with a diffusion transformer (DiT).

This repo attempted to reduce the VRAM usage of the original model so that it can be easily deployed on any kind of Apple Device with ease (with MLX). The result as can be seen, is still very usable.

Demo:

4bit (223MB)

https://github.com/user-attachments/assets/406b4624-8f7c-48a4-a35d-2108fb081744

Original (1.35GB)

https://github.com/user-attachments/assets/c8b6f7c0-65ab-4950-ac96-b10608954174

Installation

pip install f5-tts-mlx-quantized

Basic Usage

python -m f5_tts_mlx.generate --text "The quick brown fox jumped over the lazy dog."

You can also use a pipe to generate speech from the output of another process, for instance from a language model:

mlx_lm.generate --model mlx-community/Llama-3.2-1B-Instruct-4bit --verbose false \
 --temp 0 --max-tokens 512 --prompt "Write a concise paragraph explaning wavelets." \
| python -m f5_tts_mlx.generate

Voice Matching

If you want to use your own reference audio sample, make sure it's a mono, 24kHz wav file of around 5-10 seconds:

python -m f5_tts_mlx.generate \
--text "The quick brown fox jumped over the lazy dog." \
--ref-audio /path/to/audio.wav \
--ref-text "This is the caption for the reference audio."

You can convert an audio file to the correct format with ffmpeg like this:

ffmpeg -i /path/to/audio.wav -ac 1 -ar 24000 -sample_fmt s16 -t 10 /path/to/output_audio.wav

See here for more options to customize generation.

From Python

You can load a pretrained model from Python:

from f5_tts_mlx.generate import generate

audio = generate(text = "Hello world.", ...)

Pretrained model weights are also available on Hugging Face.

Appreciation

Lucas Newman for original implementation of F5 TTS on MLX

Yushen Chen for the original Pytorch implementation of F5 TTS and pretrained model.

Phil Wang for the E2 TTS implementation that this model is based on.

Citations

@article{chen-etal-2024-f5tts,
      title={F5-TTS: A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching}, 
      author={Yushen Chen and Zhikang Niu and Ziyang Ma and Keqi Deng and Chunhui Wang and Jian Zhao and Kai Yu and Xie Chen},
      journal={arXiv preprint arXiv:2410.06885},
      year={2024},
}
@inproceedings{Eskimez2024E2TE,
    title   = {E2 TTS: Embarrassingly Easy Fully Non-Autoregressive Zero-Shot TTS},
    author  = {Sefik Emre Eskimez and Xiaofei Wang and Manthan Thakker and Canrun Li and Chung-Hsien Tsai and Zhen Xiao and Hemin Yang and Zirun Zhu and Min Tang and Xu Tan and Yanqing Liu and Sheng Zhao and Naoyuki Kanda},
    year    = {2024},
    url     = {https://api.semanticscholar.org/CorpusID:270738197}
}

License

The code in this repository is released under the MIT license as found in the LICENSE file.

Metadata

Release files for f5-tts-mlx-quantized 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for f5-tts-mlx-quantized 0.1.1
File Size Uploaded Provenance Actions
f5_tts_mlx_quantized-0.1.1.tar.gz 237.0 kB Without provenance Details for f5_tts_mlx_quantized-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for f5-tts-mlx-quantized 0.1.1
File Interpreter ABI Platform Actions
f5_tts_mlx_quantized-0.1.1-py3-none-any.whl Python 3 none any Details for f5_tts_mlx_quantized-0.1.1-py3-none-any.whl

Total release size: 474.5 kB

Release files / f5_tts_mlx_quantized-0.1.1.tar.gz

Download URL f5_tts_mlx_quantized-0.1.1.tar.gz
Size 237.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2be1b3a2149958c3e504e8087b58bdd27f3a8cd03ef24bce9f193b09c47587db
BLAKE2b-256 checksum
How to use checksums
54a2959a0fb5f29edc3a275c778e997ad450052b9464198fb55dd525efd76f42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Release files / f5_tts_mlx_quantized-0.1.1-py3-none-any.whl

Download URL f5_tts_mlx_quantized-0.1.1-py3-none-any.whl
Size 237.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36c9192b2ccc822d33beec319b22c2c23b7dd91cd67747a4ccc034bc64eaaa06
BLAKE2b-256 checksum
How to use checksums
bd6a29c7faaca0ecf4a5a395015a588155a72dda5610395bd61b9e16d4f505e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.9.21

Security for f5-tts-mlx-quantized 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page