Views
No views yet
1import torch
2import numpy as np
3from transformers import AutoModel, AutoTokenizer
4
5# Load model
6model = AutoModel.from_pretrained(
7 "bosonai/higgs-audio-v3-8b-stt",
8 torch_dtype=torch.bfloat16,
9 trust_remote_code=True,
10 attn_implementation="eager",
11 device_map="cuda:0",
12)
13tokenizer = AutoTokenizer.from_pretrained("bosonai/higgs-audio-v3-8b-stt")
14
15# Transcribe audio (16kHz mono numpy array)
16from transformers.utils import cached_file
17import importlib.util
18spec = importlib.util.spec_from_file_location("transcribe", cached_file("bosonai/higgs-audio-v3-8b-stt", "transcribe.py", _raise_exceptions_for_connection_errors=False))
19mod = importlib.util.module_from_spec(spec)
20spec.loader.exec_module(mod)
21
22audio_np = np.random.randn(16000).astype(np.float32) # replace with your audio
23text = mod.transcribe(model, tokenizer, audio_np)
24print(text)torch
transformers>=4.51.0
whisper # for audio preprocessing (WhisperProcessor)| Dataset | WER |
|---|---|
| AMI | 6.23% |
| Earnings22 | 11.33% |
| GigaSpeech | 9.34% |
| LibriSpeech Clean | 1.24% |
| LibriSpeech Other | 2.34% |
| SPGISpeech | 3.14% |
| TED-LIUM | 3.14% |
| VoxPopuli | 5.63% |
| Average | 5.30% |