Documentation
¶
Overview ¶
Package whisper provides Whisper API-backed STT (OpenAI or self-hosted compatible) with configurable base URL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements services.STTService using an OpenAI-compatible transcription API. Base URL defaults to OpenAI when WHISPER_BASE_URL is empty; set it to use a self-hosted Whisper API.
func NewService ¶
NewService creates a Whisper STT service. apiKey: use WHISPER_API_KEY or OPENAI_API_KEY when empty (via config/env). baseURL: when empty, OpenAI default is used (so behavior matches OpenAI Whisper).
func (*Service) Transcribe ¶
func (s *Service) Transcribe(ctx context.Context, audio []byte, sampleRate, numChannels int) ([]*frames.TranscriptionFrame, error)
Transcribe sends audio to the Whisper API and returns one TranscriptionFrame (final). Audio is written to a temp file because the client expects a file path.
func (*Service) TranscribeStream ¶
func (s *Service) TranscribeStream(ctx context.Context, audioCh <-chan []byte, sampleRate, numChannels int, outCh chan<- frames.Frame)
TranscribeStream buffers audio from audioCh and sends final TranscriptionFrame(s) to outCh. Whisper API is not truly streaming; this batches incoming audio and transcribes when context is done or buffer is flushed.