speech

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts speech routes on the given mux.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL