Help us shape the future of Go! Take the 2026 Go Developer Survey

speech

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package speech sends audio to an OpenAI-compatible transcription endpoint (Whisper and the servers that speak its API). Callers invoke it only after a viewer asks for a subtitle track.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(base string) string

Endpoint is the transcription URL for an owner-entered base. "http://host:1234" and "http://host:1234/v1" both work.

func ExtractWAV

func ExtractWAV(ctx context.Context, ffmpegPath, input string) (path string, cleanup func(), err error)

ExtractWAV writes 16 kHz mono PCM wav for input (a file or URL ffmpeg can read). cleanup removes the file. The caller asks for this only after a viewer requests subtitles.

Types

type Client

type Client struct {
	BaseURL string
	APIKey  string
	Model   string
	HTTP    *http.Client
}

Client talks to /audio/transcriptions.

func (Client) Transcribe

func (c Client) Transcribe(ctx context.Context, audio io.Reader, filename, language string) (string, error)

Transcribe posts one audio file and returns the response body. response_format=vtt asks for timed cues. filename is the multipart name.

func (Client) TranscribeFile

func (c Client) TranscribeFile(ctx context.Context, wavPath, language string) (string, error)

TranscribeFile sends a wav, splitting it into 10-minute pieces when it is larger than one request should carry, and returns one WebVTT document.

Jump to

Keyboard shortcuts

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