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-v2",
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-v2")
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-v2", "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 | 10.14% |
| Earnings22 | 8.73% |
| GigaSpeech | 8.47% |
| LibriSpeech Clean | 1.25% |
| LibriSpeech Other | 2.38% |
| SPGISpeech | 3.60% |
| TED-LIUM | 3.09% |
| VoxPopuli | 5.92% |
| Average | 5.449% |