@mlx-node/asr

Speech to text with Qwen3-ASR, for files and live audio.

Install

bash
npm install @mlx-node/asr @mlx-node/tts

@mlx-node/tts is there for its WAV reader, which the sample below uses. If you already have the samples as a Float32Array, @mlx-node/asr alone is enough.

Get a model

The package runs Qwen3-ASR. Download the checkpoint and convert it once:

bash
mlx download model -m Qwen/Qwen3-ASR-1.7B-hf
mlx convert -i ~/.mlx-node/models/qwen3-asr-1.7b-hf \
  -o ~/.mlx-node/models/qwen3-asr-1.7b-mlx-mxfp4 -d bfloat16 -q --q-mode mxfp4

The converted folder is the one the sample loads.

Transcribe a file

ts
import { homedir } from 'node:os';
import { join } from 'node:path';

import { Qwen3AsrModel } from '@mlx-node/asr';
import { readWav } from '@mlx-node/tts';

// A mono WAV file. transcribe() resamples it to 16 kHz.
const { samples, sampleRate } = await readWav('recording.wav');

const models = join(homedir(), '.mlx-node', 'models');
const asr = await Qwen3AsrModel.load(join(models, 'qwen3-asr-1.7b-mlx-mxfp4'));
const { text } = await asr.transcribe(samples, { sampleRate });
console.log(text);
await asr.dispose();

transcribe() takes mono float samples at any sample rate and resamples them to 16 kHz inside. readWav() from @mlx-node/tts reads a whole WAV file and keeps its channels, so the sample expects a mono file. For a stereo file, open it with WavReader from the same package and read reader.chunks(16384, true): the second argument mixes each chunk down to mono.

Live audio

  • model.startTranscription(samples) returns a task you can cancel.
  • model.createStream() takes audio in pieces and gives text as it goes.
  • startRealtimeTranscription transcribes live audio as it comes in.
  • startMeetingTranscription takes the microphone and the system audio as one meeting session.

Over HTTP

mlx serve exposes the same model as POST /v1/audio/transcriptions for a WAV upload. See @mlx-node/server.

Main exports

Name What it is
Qwen3AsrModel load, transcribe, startTranscription, createStream, dispose
startRealtimeTranscription Live transcription
startMeetingTranscription The microphone and the system audio as one meeting session

Go deeper