Automatic Speech Recognition
Safetensors
GGUF
English
asr_model
audio
speech-recognition
asr
speech-to-text
qwen
qwen3.5
granite-speech
tiny-audio
custom_code
conversational
Instructions to use aaron-hu26/my-tiny-audio with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use aaron-hu26/my-tiny-audio with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf aaron-hu26/my-tiny-audio:Q8_0 # Run inference directly in the terminal: llama cli -hf aaron-hu26/my-tiny-audio:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf aaron-hu26/my-tiny-audio:Q8_0 # Run inference directly in the terminal: llama cli -hf aaron-hu26/my-tiny-audio:Q8_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf aaron-hu26/my-tiny-audio:Q8_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf aaron-hu26/my-tiny-audio:Q8_0
Use Docker
docker model run hf.co/aaron-hu26/my-tiny-audio:Q8_0
- Llama new
- LM Studio
- Jan
- Ollama
How to use aaron-hu26/my-tiny-audio with Ollama:
ollama run hf.co/aaron-hu26/my-tiny-audio:Q8_0
- Unsloth Desktop
- Pi
How to use aaron-hu26/my-tiny-audio with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf aaron-hu26/my-tiny-audio:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "aaron-hu26/my-tiny-audio:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use aaron-hu26/my-tiny-audio with Docker Model Runner:
docker model run hf.co/aaron-hu26/my-tiny-audio:Q8_0
- Lemonade
How to use aaron-hu26/my-tiny-audio with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull aaron-hu26/my-tiny-audio:Q8_0
Run and chat with the model
lemonade run user.my-tiny-audio-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use aaron-hu26/my-tiny-audio with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf aaron-hu26/my-tiny-audio:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default aaron-hu26/my-tiny-audio:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use aaron-hu26/my-tiny-audio with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf aaron-hu26/my-tiny-audio:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "aaron-hu26/my-tiny-audio:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Enable transformers pipeline (Exercise 3): add root config.json, custom modeling code, and unified model.safetensors
8af3602 verified Download alignment.py from aaron-hu26/my-tiny-audio: direct link, hf CLI and curl.
- Browser
- Download file 6.67 kB
-
https://huggingface.co/aaron-hu26/my-tiny-audio/resolve/main/alignment.py
- Command line
-
hf download hf://aaron-hu26/my-tiny-audio/alignment.py
-
curl -L -o alignment.py https://huggingface.co/aaron-hu26/my-tiny-audio/resolve/main/alignment.py
6.67 kB
| """Forced alignment for word-level timestamps with Qwen3-ForcedAligner.""" | |
| from __future__ import annotations | |
| import itertools | |
| from collections.abc import Sequence | |
| from typing import TYPE_CHECKING, TypedDict, cast | |
| import numpy as np | |
| import numpy.typing as npt | |
| import torch | |
| import torchaudio | |
| if TYPE_CHECKING: | |
| from transformers import Qwen3ASRForTokenClassification, Qwen3ASRProcessor | |
| from transformers.models.qwen3_asr.processing_qwen3_asr import ( | |
| _clean_tokens, # pyright: ignore[reportPrivateUsage] # no public word filter | |
| ) | |
| _QWEN3_ASR_IMPORT_ERROR: ImportError | None = None | |
| else: | |
| # Qwen3-ForcedAligner needs transformers >= 5.17; keep this module importable | |
| # on older versions and only fail when alignment is actually requested. | |
| try: | |
| from transformers import Qwen3ASRForTokenClassification, Qwen3ASRProcessor | |
| from transformers.models.qwen3_asr.processing_qwen3_asr import _clean_tokens | |
| _QWEN3_ASR_IMPORT_ERROR = None | |
| except ImportError as e: | |
| _QWEN3_ASR_IMPORT_ERROR = e | |
| class AlignedWord(TypedDict): | |
| """One aligned word: the original word and its span in seconds.""" | |
| word: str | |
| start: float | |
| end: float | |
| def get_device() -> torch.device: | |
| """Get best available device for inference.""" | |
| if torch.cuda.is_available(): | |
| return torch.device("cuda") | |
| if torch.backends.mps.is_available(): | |
| return torch.device("mps") | |
| return torch.device("cpu") | |
| def to_16k(audio: npt.ArrayLike | torch.Tensor, sample_rate: int) -> npt.NDArray[np.float32]: | |
| """Flatten `audio` to a float32 mono array resampled to 16 kHz.""" | |
| if isinstance(audio, torch.Tensor): | |
| audio = audio.cpu() | |
| out: npt.NDArray[np.float32] = np.asarray(audio, dtype=np.float32).reshape(-1) | |
| if sample_rate != 16000: | |
| out = np.asarray( | |
| torchaudio.functional.resample(torch.as_tensor(out), sample_rate, 16000), | |
| dtype=np.float32, | |
| ) | |
| return out | |
| class QwenForcedAligner: | |
| """Word timestamps from Qwen3-ForcedAligner-0.6B (transformers >= 5.17). | |
| Trained for timestamping rather than repurposed from CTC ASR, it aligns | |
| cased, punctuated text with numbers directly. One forward pass covers up to | |
| 5 minutes of speech, so long recordings are aligned as chunks, each against | |
| its own transcript (`align_chunks`), batched. | |
| Returns `[{"word", "start", "end"}]` for every word it can align, in order, | |
| with the ORIGINAL word (punctuation, casing) as "word". The aligner itself | |
| sees words with punctuation stripped and drops any that strip to nothing | |
| ("--"); the split is mirrored word by word so the pairing stays exact. | |
| """ | |
| MODEL_ID = "Qwen/Qwen3-ForcedAligner-0.6B-hf" | |
| MAX_SECONDS = 300.0 | |
| BATCH_SIZE = 8 | |
| _model: Qwen3ASRForTokenClassification | None = None | |
| _processor: Qwen3ASRProcessor | None = None | |
| def get_instance(cls) -> tuple[Qwen3ASRForTokenClassification, Qwen3ASRProcessor]: | |
| """Load the aligner model and processor once, then return the cached pair.""" | |
| if cls._model is None or cls._processor is None: | |
| if _QWEN3_ASR_IMPORT_ERROR is not None: | |
| raise _QWEN3_ASR_IMPORT_ERROR | |
| device = get_device() | |
| # Batches are padded, and Metal sdpa returns NaN for fully masked rows. | |
| attn = "eager" if device.type == "mps" else "sdpa" | |
| model = Qwen3ASRForTokenClassification.from_pretrained( | |
| cls.MODEL_ID, dtype=torch.bfloat16, attn_implementation=attn | |
| ) | |
| # PreTrainedModel.to is functools.wraps'd, which pyright cannot bind as a method. | |
| cast(torch.nn.Module, model).to(device) | |
| model.eval() | |
| cls._model = model | |
| cls._processor = Qwen3ASRProcessor.from_pretrained(cls.MODEL_ID) | |
| return cls._model, cls._processor | |
| def align_chunks( | |
| cls, | |
| chunks: Sequence[tuple[npt.ArrayLike | torch.Tensor, str]], | |
| sample_rate: int = 16000, | |
| language: str = "English", | |
| ) -> list[list[AlignedWord]]: | |
| """Align each `(audio, text)` pair (each <= 5 min); one word list per pair.""" | |
| if _QWEN3_ASR_IMPORT_ERROR is not None: | |
| raise _QWEN3_ASR_IMPORT_ERROR | |
| results: list[list[AlignedWord]] = [[] for _ in chunks] | |
| todo: list[tuple[int, npt.NDArray[np.float32], list[str]]] = [] | |
| for i, (raw, text) in enumerate(chunks): | |
| kept = [w for w in text.split() if _clean_tokens([w])] | |
| if not kept: | |
| continue | |
| audio = to_16k(raw, sample_rate) | |
| if len(audio) / 16000 > cls.MAX_SECONDS: | |
| msg = ( | |
| f"chunk {i} is {len(audio) / 16000:.0f} s; Qwen3-ForcedAligner takes at most " | |
| f"{cls.MAX_SECONDS:.0f} s -- cut the audio first" | |
| ) | |
| raise ValueError(msg) | |
| todo.append((i, audio, kept)) | |
| if not todo: # nothing to time: don't load the model | |
| return results | |
| model, processor = cls.get_instance() | |
| for batch in itertools.batched(todo, cls.BATCH_SIZE): | |
| features, word_lists = processor.prepare_forced_aligner_inputs( | |
| [audio for _, audio, _ in batch], | |
| [" ".join(kept) for _, _, kept in batch], | |
| language=language, | |
| return_tensors="pt", | |
| processor_kwargs={"padding": True}, | |
| ) | |
| inputs = { | |
| k: ( | |
| v.to(model.device, dtype=model.dtype) | |
| if v.is_floating_point() | |
| else v.to(model.device) | |
| ) | |
| for k, v in features.items() | |
| } | |
| logits = model(**inputs).logits | |
| timed = processor.decode_forced_alignment( | |
| logits, inputs["input_ids"], word_lists, model.config.timestamp_token_id | |
| ) | |
| for (i, _, kept), words in zip(batch, timed, strict=True): | |
| results[i] = [ | |
| {"word": w, "start": float(t["start_time"]), "end": float(t["end_time"])} | |
| for w, t in zip(kept, words, strict=True) | |
| ] | |
| return results | |
| def align( | |
| cls, | |
| audio: npt.ArrayLike | torch.Tensor, | |
| text: str, | |
| sample_rate: int = 16000, | |
| language: str = "English", | |
| ) -> list[AlignedWord]: | |
| """Align one clip of at most 5 minutes; `[{"word", "start", "end"}]`.""" | |
| return cls.align_chunks([(audio, text)], sample_rate, language)[0] | |