mlx_audio 0.1.0 copy "mlx_audio: ^0.1.0" to clipboard
mlx_audio: ^0.1.0 copied to clipboard

PlatformmacOS

On-device speech for Apple Silicon: Parakeet-TDT and Whisper speech-to-text and PocketTTS text-to-speech, built on the mlx array framework via mlx-c.

example/example.dart

// Minimal `mlx_audio` example: transcribe a WAV file with speech-to-text.
//
// Run from packages/mlx_audio:
//   dart run example/example.dart path/to/audio.wav
//
// The first run downloads `mlx-community/parakeet-tdt-0.6b-v2` into the local
// Hugging Face cache; pass a local model directory as a 2nd argument to reuse a
// checkpoint you already have.
import 'package:mlx_audio/mlx_audio.dart';

Future<void> main(List<String> args) async {
  if (args.isEmpty) {
    print('usage: dart run example/example.dart <audio.wav> [model-dir-or-repo]');
    return;
  }
  final audioPath = args[0];
  final repo = args.length > 1 ? args[1] : 'mlx-community/parakeet-tdt-0.6b-v2';

  // Load an STT model (Parakeet-TDT by default; a Whisper repo also works).
  final SttModel model = await STT.loadModel(repo);

  // Decode the audio to 16 kHz mono and transcribe it.
  final audio = await loadAudioMono16k(audioPath);
  final SttOutput out = model.generate(audio);
  print(out.text);

  // Text-to-speech (uncomment to synthesize a 24 kHz WAV instead):
  //   final tts = await TTS.loadModel('mlx-community/pocket-tts');
  //   final speech = tts.generate('Hello from the Dart port.', voice: 'alba');
  //   writeWavFloat32('hello.wav', speech.samples, speech.sampleRate);
}
1
likes
160
points
135
downloads

Documentation

API reference

Publisher

verified publisherksh.dev

Weekly Downloads

On-device speech for Apple Silicon: Parakeet-TDT and Whisper speech-to-text and PocketTTS text-to-speech, built on the mlx array framework via mlx-c.

Repository (GitHub)
View/report issues

Topics

#speech-to-text #text-to-speech #whisper #mlx #on-device-ai

License

MIT (license)

Dependencies

args, http, mlx, path, wav

More

Packages that depend on mlx_audio