NVIDIA Canary ASR model optimized for Apple Silicon with MLX
Project description
Canary MLX
NVIDIA Canary ASR model optimized for Apple Silicon using MLX.
Installation
pip install canary-mlx
Usage
Basic Transcription
from canary_mlx import load_model
# Load the model (downloads from HuggingFace automatically)
model = load_model("your-username/canary-mlx")
# Transcribe an audio file
result = model.transcribe("audio.wav", language="en")
print(result)
Load from Local Directory
from canary_mlx import load_model
# Load from a local model directory
model = load_model("./path/to/model")
With Timestamps
result = model.transcribe("audio.wav", language="en", timestamps=True)
for sentence in result.sentences:
print(f"[{sentence.start:.2f}s - {sentence.end:.2f}s] {sentence.text}")
Long Audio with Chunking
result = model.transcribe(
"long_audio.wav",
language="en",
timestamps=True,
chunk_duration=30.0, # Process in 30-second chunks
overlap_duration=15.0, # 15-second overlap between chunks
)
Supported Languages
Bulgarian (bg), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), English (en), Estonian (et), Finnish (fi), French (fr), German (de), Greek (el), Hungarian (hu), Italian (it), Latvian (lv), Lithuanian (lt), Maltese (mt), Polish (pl), Portuguese (pt), Romanian (ro), Slovak (sk), Slovenian (sl), Spanish (es), Swedish (sv), Russian (ru), Ukrainian (uk)
API Reference
load_model(path_or_hf_id, dtype=mx.bfloat16)
Load a Canary model from a local directory or HuggingFace Hub.
Parameters:
path_or_hf_id: Local path or HuggingFace model ID (e.g.,"your-username/canary-mlx")dtype: Data type for model weights (default:mx.bfloat16)
Returns: Canary model instance
model.transcribe(...)
Transcribe an audio file.
Parameters:
path: Path to audio filelanguage: Language code (e.g., "en")timestamps: Include word-level timestamps (default:False)punctuation: Include punctuation (default:True)chunk_duration: Process in chunks of this duration (optional)overlap_duration: Overlap between chunks in seconds (default:15.0)
Returns: TranscriptionResult if timestamps=True, else str
Model Conversion
To convert a NeMo Canary model to MLX format:
-
Install conversion dependencies:
pip install "canary-mlx[convert]"
-
Download and extract the NeMo model:
tar -xvf canary_model.nemo -C canary_untared
-
Run the conversion script:
python convert_nemo.py
This creates a model/ directory containing:
model.safetensors- Model weightsconfig.json- Model configurationtokenizer.model- SentencePiece tokenizer
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file canary_mlx-0.1.0.tar.gz.
File metadata
- Download URL: canary_mlx-0.1.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c427015826ec7c4c52c42f441c3de47ec4e8730ca81188e8f05acd38ea157db
|
|
| MD5 |
05abf87c18daa7d3ada073774fc9113b
|
|
| BLAKE2b-256 |
9886ee94316b208ce1d1e06996fd748ac0a0ee9ca643209cefcf1675ad74fe1f
|
File details
Details for the file canary_mlx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: canary_mlx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
102ffe8756607aa0cfaa569830ec194c8d2de386ce01d5d925049e912d2e8238
|
|
| MD5 |
f0d4d84d104368d3fa635cb5af864ed8
|
|
| BLAKE2b-256 |
81356535861adbaee067c09e06ea15295bfe5e10ae548afadefbb9264b9c7b1d
|