mlx_audio

On-device speech models for Apple Silicon, built on the mlx package: Parakeet-TDT and Whisper speech-to-text (STT) and PocketTTS text-to-speech (TTS). A pure-Dart port of mlx-audio-swift.

Platform: macOS on Apple Silicon only. See the monorepo README for the full model support matrix.

Install

dart pub add mlx_audio
dart run mlx:setup

dart run mlx:setup (provided by the mlx dependency) builds the native mlx-c libraries once into a user-level cache; the loader finds them automatically, with no environment variables. It needs git, cmake, and the Xcode command line tools and takes a couple of minutes the first time. See the mlx package README for details.

Speech-to-text

import 'package:mlx_audio/mlx_audio.dart';

final model = await STT.loadModel('mlx-community/parakeet-tdt-0.6b-v2');
final audio = await loadAudioMono16k('audio.wav');
try {
  print(model.generate(audio).text);
} finally {
  model.close();
}

Or from the CLI:

dart run mlx_audio:transcribe --audio audio.wav

Text-to-speech

final tts = await TTS.loadModel('mlx-community/pocket-tts');
try {
  final out = tts.generate(
    'Hello world.',
    voice: 'alba',
    onAudioChunk: (chunk) {
      // PCM is available here while synthesis is still running.
      print('received ${chunk.samples.length} PCM samples');
    },
  );
  writeWavFloat32('hello.wav', out.samples, out.sampleRate);
} finally {
  tts.close();
}

Both model interfaces accept cooperative cancellation and generation-progress callbacks. close() is deterministic and idempotent. PocketTTS's onAudioChunk callback receives owned float32 PCM codec frames incrementally; the returned TtsOutput remains the complete waveform for compatibility.

dart run mlx_audio:say --text "Hello world." --voice alba --output hello.wav

See the monorepo README for CLI options, supported checkpoints, and the quantized-model support matrix.

Libraries

mlx_audio
On-device speech models for MLX on Apple Silicon: Parakeet-TDT and Whisper speech-to-text and PocketTTS text-to-speech.