stt

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package stt provides a provider-agnostic interface for speech-to-text transcription.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	// Text is the full transcript.
	Text string
	// Language is the detected or requested IETF language tag.
	Language string
	// Duration is the total audio length in seconds.
	Duration float64
	// Segments contains sentence-level chunks (when available).
	Segments []Segment
	// Words contains word-level timing (when available).
	Words []Word
	// Model identifies which model produced the transcript.
	Model string
}

Response is the canonical transcription result.

type Segment

type Segment struct {
	ID    int     `json:"id"`
	Start float64 `json:"start"`
	End   float64 `json:"end"`
	Text  string  `json:"text"`
}

Segment is a sentence-level transcript chunk.

type SpeechToText

type SpeechToText interface {
	// Transcribe converts audio bytes to text.
	// audioData must be in a format the provider accepts (MP3, WAV, WebM, …).
	Transcribe(ctx context.Context, audioData []byte) (*Response, error)
	// Provider returns a stable provider name (e.g. "openai", "deepgram").
	Provider() string
}

SpeechToText is the core interface for transcription providers. Implementations must be safe for concurrent use.

type Word

type Word struct {
	Word       string  `json:"word"`
	Start      float64 `json:"start"` // seconds from audio start
	End        float64 `json:"end"`   // seconds from audio start
	Confidence float64 `json:"confidence"`
}

Word holds per-word timing and confidence data (when the provider returns it).

Jump to

Keyboard shortcuts

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