Documentation
¶
Overview ¶
Package huggingface adapts the Hugging Face Inference API (the hf-inference route on router.huggingface.co) to stt.STTProvider for hosted ASR models such as Whisper. It needs a Hugging Face access token and public https egress; the model is addressed by its hub id and may answer 503 while it loads.
Stability: Beta — API-checked; may change with a changelog callout.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶ added in v0.74.0
type Options struct {
// APIKey is the HuggingFace access token (an "hf_..." user token).
APIKey string
// Model is the HuggingFace model id, for example "openai/whisper-large-v3".
Model string
}
Options configures New.
type Provider ¶
type Provider struct {
Model string
Token string
BaseURL string // Override for testing; defaults to hfBaseURL
Validation netsec.ValidationOptions
// contains filtered or unexported fields
}
Provider implements stt.STTProvider for Tier 3: HuggingFace Inference API.
BaseURL is user-configurable. It is validated against Validation on every request. Default Validation is strict (public https only).
func (*Provider) Capabilities ¶ added in v0.64.3
func (*Provider) Capabilities() []speechkit.Capability
Capabilities reports the speech-to-text baseline every provider satisfies.
func (*Provider) Health ¶ added in v0.64.3
Health issues an authenticated GET on the configured model's endpoint. A 503 is reported as the model still loading; any other non-200 status is a status error.
func (*Provider) Transcribe ¶ added in v0.64.3
func (p *Provider) Transcribe(ctx context.Context, audio []byte, opts stt.TranscribeOpts) (*stt.Result, error)
Transcribe implements stt.STTProvider: it posts the audio bytes as-is (audio/wav) to the inference endpoint of opts.Model, else the configured Model. No language is sent or returned, so the result Language echoes the requested locale or "multi". A 503 means the model is still loading and a 429 that the account is rate-limited; both surface as status errors.