Instructions to use ibm-granite/granite-4.0-1b-speech with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ibm-granite/granite-4.0-1b-speech with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="ibm-granite/granite-4.0-1b-speech")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("ibm-granite/granite-4.0-1b-speech") model = AutoModelForMultimodalLM.from_pretrained("ibm-granite/granite-4.0-1b-speech", device_map="auto") - Notebooks
- Google Colab
- Kaggle
added mlx-audio support
Browse files
README.md
CHANGED
|
@@ -237,6 +237,33 @@ print(f"Audio Example - Question: {question}")
|
|
| 237 |
print(f"Generated text: {chat_completion_with_audio.choices[0].message.content}")
|
| 238 |
```
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
**Model Architecture:**
|
| 241 |
|
| 242 |
The architecture of granite-4.0-1b-speech consists of the following components:
|
|
|
|
| 237 |
print(f"Generated text: {chat_completion_with_audio.choices[0].message.content}")
|
| 238 |
```
|
| 239 |
|
| 240 |
+
### Usage with `mlx-audio` for Apple Silicon M series chips
|
| 241 |
+
|
| 242 |
+
First, install a recent version of mlx-audio (0.4.1 or later):
|
| 243 |
+
```shell
|
| 244 |
+
pip install -U mlx-audio
|
| 245 |
+
```
|
| 246 |
+
CLI:
|
| 247 |
+
```shell
|
| 248 |
+
python -m mlx_audio.stt.generate --model ibm-granite/granite-4.0-1b-speech --verbose --audio "audio.wav" --output-path "transcript"
|
| 249 |
+
```
|
| 250 |
+
Python:
|
| 251 |
+
```python
|
| 252 |
+
from mlx_audio.stt.utils import load_model
|
| 253 |
+
from mlx_audio.stt.generate import generate_transcription
|
| 254 |
+
|
| 255 |
+
model = load_model("mlx-community/granite-4.0-1b-speech-8bit")
|
| 256 |
+
transcription = generate_transcription(
|
| 257 |
+
model=model,
|
| 258 |
+
audio="audio.wav",
|
| 259 |
+
output_path="transcript.txt",
|
| 260 |
+
format="txt",
|
| 261 |
+
verbose=True,
|
| 262 |
+
)
|
| 263 |
+
print(transcription.text)
|
| 264 |
+
```
|
| 265 |
+
(other quantizations available at [mlx-community](https://huggingface.co/mlx-community))
|
| 266 |
+
|
| 267 |
**Model Architecture:**
|
| 268 |
|
| 269 |
The architecture of granite-4.0-1b-speech consists of the following components:
|