Automatic Speech Recognition
Transformers
Safetensors
English
asr_model
asr
speech-recognition
speech-to-text
audio
speech-llm
word-timestamps
speaker-diarization
qwen
granite-speech
lora
custom_code
Eval Results (legacy)
Instructions to use mazesmazes/tiny-audio with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mazesmazes/tiny-audio with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("automatic-speech-recognition", model="mazesmazes/tiny-audio", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForSpeechSeq2Seq model = AutoModelForSpeechSeq2Seq.from_pretrained("mazesmazes/tiny-audio", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update custom model files, README, and requirements
Browse files- alignment.py +3 -2
- asr_processing.py +6 -3
- requirements.txt +10 -5
alignment.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
-
import itertools
|
| 6 |
from collections.abc import Sequence
|
| 7 |
from typing import TYPE_CHECKING, TypedDict
|
| 8 |
|
|
@@ -127,7 +126,9 @@ class QwenForcedAligner:
|
|
| 127 |
if not todo: # nothing to time: don't load the model
|
| 128 |
return results
|
| 129 |
model, processor = cls.get_instance()
|
| 130 |
-
|
|
|
|
|
|
|
| 131 |
features, word_lists = processor.prepare_forced_aligner_inputs(
|
| 132 |
[audio for _, audio, _ in batch],
|
| 133 |
[" ".join(kept) for _, _, kept in batch],
|
|
|
|
| 2 |
|
| 3 |
from __future__ import annotations
|
| 4 |
|
|
|
|
| 5 |
from collections.abc import Sequence
|
| 6 |
from typing import TYPE_CHECKING, TypedDict
|
| 7 |
|
|
|
|
| 126 |
if not todo: # nothing to time: don't load the model
|
| 127 |
return results
|
| 128 |
model, processor = cls.get_instance()
|
| 129 |
+
# Slices, not itertools.batched (3.12+): the Hub copy runs on Python 3.11.
|
| 130 |
+
for start in range(0, len(todo), cls.BATCH_SIZE):
|
| 131 |
+
batch = todo[start : start + cls.BATCH_SIZE]
|
| 132 |
features, word_lists = processor.prepare_forced_aligner_inputs(
|
| 133 |
[audio for _, audio, _ in batch],
|
| 134 |
[" ".join(kept) for _, _, kept in batch],
|
asr_processing.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""Processor that turns raw audio (and optional text) into model inputs."""
|
| 2 |
|
| 3 |
from collections.abc import Mapping, Sequence
|
| 4 |
-
from typing import TYPE_CHECKING, Any, ClassVar, cast, overload
|
| 5 |
|
| 6 |
import numpy as np
|
| 7 |
import numpy.typing as npt
|
|
@@ -111,12 +111,15 @@ def left_pad_prompt_rows(
|
|
| 111 |
return input_ids, attention_mask
|
| 112 |
|
| 113 |
|
|
|
|
|
|
|
|
|
|
| 114 |
@overload
|
| 115 |
-
def prepend_lead_in
|
| 116 |
audio: npt.NDArray[ScalarT], sampling_rate: int, seconds: float | None
|
| 117 |
) -> npt.NDArray[ScalarT]: ...
|
| 118 |
@overload
|
| 119 |
-
def prepend_lead_in
|
| 120 |
audio: list[npt.NDArray[ScalarT]], sampling_rate: int, seconds: float | None
|
| 121 |
) -> list[npt.NDArray[ScalarT]]: ...
|
| 122 |
@overload
|
|
|
|
| 1 |
"""Processor that turns raw audio (and optional text) into model inputs."""
|
| 2 |
|
| 3 |
from collections.abc import Mapping, Sequence
|
| 4 |
+
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar, cast, overload
|
| 5 |
|
| 6 |
import numpy as np
|
| 7 |
import numpy.typing as npt
|
|
|
|
| 111 |
return input_ids, attention_mask
|
| 112 |
|
| 113 |
|
| 114 |
+
ScalarT = TypeVar("ScalarT", bound=np.generic)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
@overload
|
| 118 |
+
def prepend_lead_in(
|
| 119 |
audio: npt.NDArray[ScalarT], sampling_rate: int, seconds: float | None
|
| 120 |
) -> npt.NDArray[ScalarT]: ...
|
| 121 |
@overload
|
| 122 |
+
def prepend_lead_in(
|
| 123 |
audio: list[npt.NDArray[ScalarT]], sampling_rate: int, seconds: float | None
|
| 124 |
) -> list[npt.NDArray[ScalarT]]: ...
|
| 125 |
@overload
|
requirements.txt
CHANGED
|
@@ -5,11 +5,16 @@
|
|
| 5 |
# Speaker diarization (return_speakers=True) uses Nemotron-3-Diarization, which is in
|
| 6 |
# transformers main after 5.17 -- pinned to the commit the pipeline was verified on.
|
| 7 |
transformers @ git+https://github.com/huggingface/transformers@91ea1192a00e0ebb684400434375fbd2345c8449
|
| 8 |
-
#
|
| 9 |
-
#
|
| 10 |
-
#
|
| 11 |
-
torch
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
peft
|
| 14 |
safetensors
|
| 15 |
numpy
|
|
|
|
| 5 |
# Speaker diarization (return_speakers=True) uses Nemotron-3-Diarization, which is in
|
| 6 |
# transformers main after 5.17 -- pinned to the commit the pipeline was verified on.
|
| 7 |
transformers @ git+https://github.com/huggingface/transformers@91ea1192a00e0ebb684400434375fbd2345c8449
|
| 8 |
+
# The Inference Endpoints image ships an older torch, torchvision and torchaudio.
|
| 9 |
+
# Pin all three as one matching set (torch 2.8, as in poetry.lock): a bare
|
| 10 |
+
# "torch" keeps the image's version, which this transformers rejects (< 2.5),
|
| 11 |
+
# and upgrading torch alone leaves the image's torchvision built for the old
|
| 12 |
+
# one, so transformers' torchvision import fails ("operator torchvision::nms
|
| 13 |
+
# does not exist", surfacing as "Could not import module
|
| 14 |
+
# 'WhisperForConditionalGeneration'").
|
| 15 |
+
torch==2.8.0
|
| 16 |
+
torchvision==0.23.0
|
| 17 |
+
torchaudio==2.8.0
|
| 18 |
peft
|
| 19 |
safetensors
|
| 20 |
numpy
|