Automatic Speech Recognition
NeMo
Safetensors
PyTorch
Transformers
English
parakeet_rnnt
feature-extraction
speech
audio
Transducer
FastConformer
Conformer
NeMo
hf-asr-leaderboard
Eval Results (legacy)
Eval Results
Instructions to use nvidia/parakeet-rnnt-0.6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- NeMo
How to use nvidia/parakeet-rnnt-0.6b with NeMo:
import nemo.collections.asr as nemo_asr asr_model = nemo_asr.models.ASRModel.from_pretrained("nvidia/parakeet-rnnt-0.6b") transcriptions = asr_model.transcribe(["file.wav"]) - Transformers
How to use nvidia/parakeet-rnnt-0.6b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="nvidia/parakeet-rnnt-0.6b")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/parakeet-rnnt-0.6b", dtype="auto") - Notebooks
- Google Colab
- Kaggle
Add 🤗 Transformers support
#4
by eustlb HF Staff - opened
- README.md +120 -11
- config.json +42 -0
- generation_config.json +8 -0
- model.safetensors +3 -0
- processor_config.json +17 -0
- tokenizer.json +0 -0
- tokenizer_config.json +9 -0
README.md
CHANGED
|
@@ -27,6 +27,7 @@ tags:
|
|
| 27 |
- pytorch
|
| 28 |
- NeMo
|
| 29 |
- hf-asr-leaderboard
|
|
|
|
| 30 |
license: cc-by-4.0
|
| 31 |
widget:
|
| 32 |
- example_title: Librispeech sample 1
|
|
@@ -197,25 +198,27 @@ NVIDIA Developer [Nemotron](https://developer.nvidia.com/nemotron)<br>
|
|
| 197 |
[NVIDIA Riva Speech](https://developer.nvidia.com/riva?sortBy=developer_learning_library%2Fsort%2Ffeatured_in.riva%3Adesc%2Ctitle%3Aasc#demos)<br>
|
| 198 |
[NeMo Documentation](https://docs.nvidia.com/nemo-framework/user-guide/latest/nemotoolkit/asr/models.html)<br>
|
| 199 |
|
| 200 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
To train, fine-tune or play with the model you will need to install [NVIDIA NeMo](https://github.com/NVIDIA/NeMo). We recommend you install it after you've installed latest PyTorch version.
|
| 203 |
```
|
| 204 |
pip install nemo_toolkit['all']
|
| 205 |
```
|
| 206 |
|
| 207 |
-
##
|
| 208 |
-
|
| 209 |
-
The model is available for use in the NeMo toolkit [3], and can be used as a pre-trained checkpoint for inference or for fine-tuning on another dataset.
|
| 210 |
-
|
| 211 |
-
### Automatically instantiate the model
|
| 212 |
|
| 213 |
```python
|
| 214 |
import nemo.collections.asr as nemo_asr
|
| 215 |
asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained(model_name="nvidia/parakeet-rnnt-0.6b")
|
| 216 |
```
|
| 217 |
|
| 218 |
-
### Transcribing using Python
|
| 219 |
First, let's get a sample
|
| 220 |
```
|
| 221 |
wget https://dldata-public.s3.us-east-2.amazonaws.com/2086-149220-0033.wav
|
|
@@ -226,7 +229,7 @@ output = asr_model.transcribe(['2086-149220-0033.wav'])
|
|
| 226 |
print(output[0].text)
|
| 227 |
```
|
| 228 |
|
| 229 |
-
### Transcribing many audio files
|
| 230 |
|
| 231 |
```shell
|
| 232 |
python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py
|
|
@@ -234,6 +237,114 @@ python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py
|
|
| 234 |
audio_dir="<DIRECTORY CONTAINING AUDIO FILES>"
|
| 235 |
```
|
| 236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
### Input
|
| 238 |
|
| 239 |
This model accepts 16000 Hz mono-channel audio (wav files) as input.
|
|
@@ -303,6 +414,4 @@ Check out [Riva live demo](https://developer.nvidia.com/riva#demos).
|
|
| 303 |
|
| 304 |
[4] [Suno.ai](https://suno.ai/)
|
| 305 |
|
| 306 |
-
[5] [HuggingFace ASR Leaderboard](https://huggingface.co/spaces/hf-audio/open_asr_leaderboard)
|
| 307 |
-
|
| 308 |
-
|
|
|
|
| 27 |
- pytorch
|
| 28 |
- NeMo
|
| 29 |
- hf-asr-leaderboard
|
| 30 |
+
- transformers
|
| 31 |
license: cc-by-4.0
|
| 32 |
widget:
|
| 33 |
- example_title: Librispeech sample 1
|
|
|
|
| 198 |
[NVIDIA Riva Speech](https://developer.nvidia.com/riva?sortBy=developer_learning_library%2Fsort%2Ffeatured_in.riva%3Adesc%2Ctitle%3Aasc#demos)<br>
|
| 199 |
[NeMo Documentation](https://docs.nvidia.com/nemo-framework/user-guide/latest/nemotoolkit/asr/models.html)<br>
|
| 200 |
|
| 201 |
+
## How to Use this Model
|
| 202 |
+
|
| 203 |
+
The model is available for use in the NeMo toolkit [3], and can be used as a pre-trained checkpoint for inference or for fine-tuning on another dataset.
|
| 204 |
+
|
| 205 |
+
You can also run Parakeet RNNT with [Transformers](https://github.com/huggingface/transformers) 🤗 (more below).
|
| 206 |
+
|
| 207 |
+
### 1) NeMo usage
|
| 208 |
|
| 209 |
To train, fine-tune or play with the model you will need to install [NVIDIA NeMo](https://github.com/NVIDIA/NeMo). We recommend you install it after you've installed latest PyTorch version.
|
| 210 |
```
|
| 211 |
pip install nemo_toolkit['all']
|
| 212 |
```
|
| 213 |
|
| 214 |
+
#### Automatically instantiate the model
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
|
| 216 |
```python
|
| 217 |
import nemo.collections.asr as nemo_asr
|
| 218 |
asr_model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained(model_name="nvidia/parakeet-rnnt-0.6b")
|
| 219 |
```
|
| 220 |
|
| 221 |
+
#### Transcribing using Python
|
| 222 |
First, let's get a sample
|
| 223 |
```
|
| 224 |
wget https://dldata-public.s3.us-east-2.amazonaws.com/2086-149220-0033.wav
|
|
|
|
| 229 |
print(output[0].text)
|
| 230 |
```
|
| 231 |
|
| 232 |
+
#### Transcribing many audio files
|
| 233 |
|
| 234 |
```shell
|
| 235 |
python [NEMO_GIT_FOLDER]/examples/asr/transcribe_speech.py
|
|
|
|
| 237 |
audio_dir="<DIRECTORY CONTAINING AUDIO FILES>"
|
| 238 |
```
|
| 239 |
|
| 240 |
+
### 2) [Transformers](https://github.com/huggingface/transformers) 🤗 usage
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
Until Parakeet RNNT is part of an official Transformers release, you can use it by installing from source.
|
| 244 |
+
|
| 245 |
+
```bash
|
| 246 |
+
pip install git+https://github.com/huggingface/transformers
|
| 247 |
+
```
|
| 248 |
+
|
| 249 |
+
<details>
|
| 250 |
+
<summary>➡️ Pipeline usage</summary>
|
| 251 |
+
|
| 252 |
+
```python
|
| 253 |
+
from transformers import pipeline
|
| 254 |
+
|
| 255 |
+
pipe = pipeline("automatic-speech-recognition", model="eustlb/parakeet-rnnt-0.6b")
|
| 256 |
+
out = pipe("https://huggingface.co/datasets/hf-internal-testing/dummy-audio-samples/resolve/main/bcn_weather.mp3")
|
| 257 |
+
print(out)
|
| 258 |
+
```
|
| 259 |
+
</details>
|
| 260 |
+
|
| 261 |
+
<details>
|
| 262 |
+
<summary>➡️ AutoModel</summary>
|
| 263 |
+
|
| 264 |
+
```python
|
| 265 |
+
from transformers import AutoModelForRNNT, AutoProcessor
|
| 266 |
+
from datasets import load_dataset, Audio
|
| 267 |
+
|
| 268 |
+
num_samples = 3
|
| 269 |
+
|
| 270 |
+
model_id = "eustlb/parakeet-rnnt-0.6b"
|
| 271 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 272 |
+
model = AutoModelForRNNT.from_pretrained(model_id, dtype="auto", device_map="auto")
|
| 273 |
+
|
| 274 |
+
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
| 275 |
+
ds = ds.cast_column("audio", Audio(sampling_rate=processor.feature_extractor.sampling_rate))
|
| 276 |
+
speech_samples = [el["array"] for el in ds["audio"][:num_samples]]
|
| 277 |
+
|
| 278 |
+
inputs = processor(speech_samples, sampling_rate=processor.feature_extractor.sampling_rate)
|
| 279 |
+
inputs.to(model.device, dtype=model.dtype)
|
| 280 |
+
output = model.generate(**inputs, return_dict_in_generate=True)
|
| 281 |
+
print(processor.decode(output.sequences, skip_special_tokens=True))
|
| 282 |
+
```
|
| 283 |
+
</details>
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
<details>
|
| 287 |
+
<summary>➡️ Timestamping</summary>
|
| 288 |
+
|
| 289 |
+
```python
|
| 290 |
+
from datasets import Audio, load_dataset
|
| 291 |
+
from transformers import AutoModelForRNNT, AutoProcessor
|
| 292 |
+
|
| 293 |
+
num_samples = 3
|
| 294 |
+
|
| 295 |
+
model_id = "eustlb/parakeet-rnnt-0.6b"
|
| 296 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 297 |
+
model = AutoModelForRNNT.from_pretrained(model_id, dtype="auto", device_map="auto")
|
| 298 |
+
|
| 299 |
+
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
| 300 |
+
ds = ds.cast_column("audio", Audio(sampling_rate=processor.feature_extractor.sampling_rate))
|
| 301 |
+
speech_samples = [el["array"] for el in ds["audio"][:num_samples]]
|
| 302 |
+
|
| 303 |
+
inputs = processor(speech_samples, sampling_rate=processor.feature_extractor.sampling_rate)
|
| 304 |
+
inputs.to(model.device, dtype=model.dtype)
|
| 305 |
+
output = model.generate(**inputs, return_dict_in_generate=True)
|
| 306 |
+
decoded_output, decoded_timestamps = processor.decode(
|
| 307 |
+
output.sequences,
|
| 308 |
+
durations=output.durations,
|
| 309 |
+
skip_special_tokens=True,
|
| 310 |
+
)
|
| 311 |
+
print("Transcription:", decoded_output)
|
| 312 |
+
print("Timestamped tokens:", decoded_timestamps)
|
| 313 |
+
```
|
| 314 |
+
</details>
|
| 315 |
+
|
| 316 |
+
<details>
|
| 317 |
+
<summary>➡️ Training</summary>
|
| 318 |
+
|
| 319 |
+
```python
|
| 320 |
+
from transformers import AutoModelForRNNT, AutoProcessor
|
| 321 |
+
from datasets import load_dataset, Audio
|
| 322 |
+
import torch
|
| 323 |
+
|
| 324 |
+
model_id = "eustlb/parakeet-rnnt-0.6b"
|
| 325 |
+
NUM_SAMPLES = 4
|
| 326 |
+
|
| 327 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 328 |
+
model = AutoModelForRNNT.from_pretrained(model_id, dtype=torch.bfloat16, device_map="auto")
|
| 329 |
+
model.train()
|
| 330 |
+
|
| 331 |
+
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
|
| 332 |
+
ds = ds.cast_column("audio", Audio(sampling_rate=processor.feature_extractor.sampling_rate))
|
| 333 |
+
speech_samples = [el["array"] for el in ds["audio"][:NUM_SAMPLES]]
|
| 334 |
+
text_samples = ds["text"][:NUM_SAMPLES]
|
| 335 |
+
|
| 336 |
+
# passing `text` to the processor will prepare inputs' `labels` key
|
| 337 |
+
inputs = processor(audio=speech_samples, text=text_samples, sampling_rate=processor.feature_extractor.sampling_rate)
|
| 338 |
+
inputs.to(device=model.device, dtype=model.dtype)
|
| 339 |
+
|
| 340 |
+
outputs = model(**inputs)
|
| 341 |
+
print("Loss:", outputs.loss.item())
|
| 342 |
+
outputs.loss.backward()
|
| 343 |
+
```
|
| 344 |
+
</details>
|
| 345 |
+
|
| 346 |
+
For more details about usage, please refer to the [Transformers' documentation](https://huggingface.co/docs/transformers/en/model_doc/parakeet).
|
| 347 |
+
|
| 348 |
### Input
|
| 349 |
|
| 350 |
This model accepts 16000 Hz mono-channel audio (wav files) as input.
|
|
|
|
| 414 |
|
| 415 |
[4] [Suno.ai](https://suno.ai/)
|
| 416 |
|
| 417 |
+
[5] [HuggingFace ASR Leaderboard](https://huggingface.co/spaces/hf-audio/open_asr_leaderboard)
|
|
|
|
|
|
config.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"ParakeetForRNNT"
|
| 4 |
+
],
|
| 5 |
+
"blank_token_id": 1024,
|
| 6 |
+
"decoder_hidden_size": 640,
|
| 7 |
+
"dtype": "float32",
|
| 8 |
+
"encoder_config": {
|
| 9 |
+
"activation_dropout": 0.1,
|
| 10 |
+
"attention_bias": true,
|
| 11 |
+
"attention_dropout": 0.1,
|
| 12 |
+
"conv_kernel_size": 9,
|
| 13 |
+
"convolution_bias": true,
|
| 14 |
+
"dropout": 0.1,
|
| 15 |
+
"dropout_positions": 0.0,
|
| 16 |
+
"hidden_act": "silu",
|
| 17 |
+
"hidden_size": 1024,
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"intermediate_size": 4096,
|
| 20 |
+
"layerdrop": 0.1,
|
| 21 |
+
"max_position_embeddings": 5000,
|
| 22 |
+
"model_type": "parakeet_encoder",
|
| 23 |
+
"num_attention_heads": 8,
|
| 24 |
+
"num_hidden_layers": 24,
|
| 25 |
+
"num_key_value_heads": 8,
|
| 26 |
+
"num_mel_bins": 80,
|
| 27 |
+
"scale_input": true,
|
| 28 |
+
"subsampling_conv_channels": 256,
|
| 29 |
+
"subsampling_conv_kernel_size": 3,
|
| 30 |
+
"subsampling_conv_stride": 2,
|
| 31 |
+
"subsampling_factor": 8
|
| 32 |
+
},
|
| 33 |
+
"hidden_act": "relu",
|
| 34 |
+
"initializer_range": 0.02,
|
| 35 |
+
"is_encoder_decoder": true,
|
| 36 |
+
"max_symbols_per_step": 10,
|
| 37 |
+
"model_type": "parakeet_rnnt",
|
| 38 |
+
"num_decoder_layers": 2,
|
| 39 |
+
"pad_token_id": 0,
|
| 40 |
+
"transformers_version": "5.10.0.dev0",
|
| 41 |
+
"vocab_size": 1025
|
| 42 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"decoder_start_token_id": 1024,
|
| 4 |
+
"output_attentions": false,
|
| 5 |
+
"output_hidden_states": false,
|
| 6 |
+
"pad_token_id": 0,
|
| 7 |
+
"transformers_version": "5.10.0.dev0"
|
| 8 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d1f2147f87016f16557bd2bdba5644a756f008468260752cbf281cc719a2a551
|
| 3 |
+
size 2467077452
|
processor_config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"blank_token": "<blank>",
|
| 3 |
+
"decoder_type": "rnnt",
|
| 4 |
+
"feature_extractor": {
|
| 5 |
+
"feature_extractor_type": "ParakeetFeatureExtractor",
|
| 6 |
+
"feature_size": 80,
|
| 7 |
+
"hop_length": 160,
|
| 8 |
+
"n_fft": 512,
|
| 9 |
+
"padding_side": "right",
|
| 10 |
+
"padding_value": 0.0,
|
| 11 |
+
"preemphasis": 0.97,
|
| 12 |
+
"return_attention_mask": true,
|
| 13 |
+
"sampling_rate": 16000,
|
| 14 |
+
"win_length": 400
|
| 15 |
+
},
|
| 16 |
+
"processor_class": "ParakeetProcessor"
|
| 17 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"clean_up_tokenization_spaces": false,
|
| 4 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 5 |
+
"pad_token": "<blank>",
|
| 6 |
+
"processor_class": "ParakeetProcessor",
|
| 7 |
+
"tokenizer_class": "ParakeetTokenizer",
|
| 8 |
+
"unk_token": "<unk>"
|
| 9 |
+
}
|