Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves speech transcription endpoints.
func NewHandler ¶
func NewHandler(t Transcriber, opts ...HandlerOption) *Handler
NewHandler creates a speech handler with the given transcriber.
type HandlerOption ¶
type HandlerOption func(*Handler)
HandlerOption customises the speech handler.
func WithMaxUploadSize ¶
func WithMaxUploadSize(n int64) HandlerOption
WithMaxUploadSize overrides the maximum upload size in bytes.
type OpenAITranscriber ¶
type OpenAITranscriber struct {
// contains filtered or unexported fields
}
OpenAITranscriber uses the OpenAI Whisper API for speech transcription.
func NewOpenAITranscriber ¶
func NewOpenAITranscriber(apiKey string, opts ...TranscriberOption) *OpenAITranscriber
NewOpenAITranscriber creates a transcriber backed by the OpenAI Whisper API.
func (*OpenAITranscriber) Transcribe ¶
func (t *OpenAITranscriber) Transcribe(ctx context.Context, filename string, audio io.Reader) (string, error)
Transcribe sends audio to the OpenAI Whisper API and returns the transcribed text.
type Transcriber ¶
type Transcriber interface {
Transcribe(ctx context.Context, filename string, audio io.Reader) (string, error)
}
Transcriber converts audio to text.
type TranscriberOption ¶
type TranscriberOption func(*OpenAITranscriber)
TranscriberOption customises the OpenAI transcriber.
func WithTranscriberBaseURL ¶
func WithTranscriberBaseURL(u string) TranscriberOption
WithTranscriberBaseURL overrides the OpenAI API base URL.
func WithTranscriberHTTPClient ¶
func WithTranscriberHTTPClient(c *http.Client) TranscriberOption
WithTranscriberHTTPClient overrides the HTTP client.
func WithTranscriberModel ¶
func WithTranscriberModel(m string) TranscriberOption
WithTranscriberModel overrides the Whisper model name.