Skip to main content

F5-TTS - MLX

Project description

F5 TTS diagram

F5 TTS — MLX

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).

You can listen to a sample here that was generated in ~11 seconds on an M3 Max MacBook Pro.

F5 is an evolution of E2 TTS and improves performance with ConvNeXT v2 blocks for the learned text alignment. This repository is based on the original Pytorch implementation available here.

Installation

pip install f5-tts-mlx

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 \
--prompt "Write a concise paragraph explaning wavelets as used in signal processing." \
| 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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

f5_tts_mlx-0.2.0.tar.gz (234.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

f5_tts_mlx-0.2.0-py3-none-any.whl (233.8 kB view details)

Uploaded Python 3

File details

Details for the file f5_tts_mlx-0.2.0.tar.gz.

File metadata

  • Download URL: f5_tts_mlx-0.2.0.tar.gz
  • Upload date:
  • Size: 234.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for f5_tts_mlx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b9a461526f059634696033bcb0835144882b110c3e06d5cfa651a0bc88d3dd44
MD5 2aff424b5b87b98c97ecf086707d441c
BLAKE2b-256 da39fd9ddc90b5f0113ac2fcb11c17533318172471370206077810877876ff85

See more details on using hashes here.

File details

Details for the file f5_tts_mlx-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: f5_tts_mlx-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 233.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for f5_tts_mlx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ba4d3dd3a6352687267a6734dbae8d12e6cd063422e7be4c595e8c725c58cbf
MD5 f2bbec0c44b873e56e627eb20f67745b
BLAKE2b-256 71d726a5aac6ca4394e2e2437d152c874894e1607a31b541ec73e4b040be51cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page