stt

package
v1.833.49 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlibabacloudSpeechToTextProvider

type AlibabacloudSpeechToTextProvider struct {
	// contains filtered or unexported fields
}

func NewAlibabacloudSpeechToTextProvider

func NewAlibabacloudSpeechToTextProvider(typ string, subType string, secretKey string) (*AlibabacloudSpeechToTextProvider, error)

NewAlibabacloudSpeechToTextProvider creates a new instance of the Alibabacloud STT provider

func (*AlibabacloudSpeechToTextProvider) GetPricing

func (p *AlibabacloudSpeechToTextProvider) GetPricing() string

GetPricing returns the pricing information for Alibabacloud ASR service

func (*AlibabacloudSpeechToTextProvider) ProcessAudio

func (p *AlibabacloudSpeechToTextProvider) ProcessAudio(audioReader io.Reader, ctx context.Context, lang string, want []Timing) (*Transcript, *SpeechToTextResult, error)

ProcessAudio processes an audio stream and returns the transcribed text. want is ignored: this upstream reports no timestamps, so the transcript it returns is text alone rather than timings invented to fill the shape.

type OpenAISpeechToTextProvider added in v1.832.35

type OpenAISpeechToTextProvider struct {
	// contains filtered or unexported fields
}

OpenAISpeechToTextProvider forwards to any OpenAI-compatible /v1/audio/transcriptions endpoint — OpenAI itself, the in-cluster speech service, or a BYO node. providerUrl is the OpenAI-compatible /v1 root (mirroring AIBaseURL's convention); the provider appends the path. subType is the upstream model (whisper family); language, when set, is the audio's ISO-639-1 language hint, forwarded as the `language` form field.

func NewOpenAISpeechToTextProvider added in v1.832.35

func NewOpenAISpeechToTextProvider(subType string, clientSecret string, providerUrl string, language string) (*OpenAISpeechToTextProvider, error)

func (*OpenAISpeechToTextProvider) GetPricing added in v1.832.35

func (p *OpenAISpeechToTextProvider) GetPricing() string

func (*OpenAISpeechToTextProvider) ProcessAudio added in v1.832.35

func (p *OpenAISpeechToTextProvider) ProcessAudio(audioData io.Reader, ctx context.Context, lang string, want []Timing) (*Transcript, *SpeechToTextResult, error)

ProcessAudio posts the audio as an OpenAI multipart transcription request and returns the transcribed text. lang is the caller's UI language (error localization elsewhere); the audio language hint is p.language.

type SpeechSegment

type SpeechSegment struct {
	Text       string
	BeginTime  float64
	EndTime    float64
	IsComplete bool
}

SpeechSegment represents a single segment of transcribed speech

type SpeechToTextProvider

type SpeechToTextProvider interface {
	GetPricing() string
	// want names the timings to ask the upstream for. Nil asks for none, and a
	// provider that cannot produce them returns a Transcript of text alone.
	ProcessAudio(audioData io.Reader, ctx context.Context, lang string, want []Timing) (*Transcript, *SpeechToTextResult, error)
}

func GetSpeechToTextProvider

func GetSpeechToTextProvider(typ string, subType string, clientSecret string, providerUrl string, flavor string) (SpeechToTextProvider, error)

GetSpeechToTextProvider creates a new provider instance based on the provider type. flavor mirrors the TTS factory's parameter: for STT it is the audio's language hint (ISO-639-1), bound onto the provider row by the caller.

type SpeechToTextResult

type SpeechToTextResult struct {
	AudioDurationSeconds float64
	Price                float64
	Currency             string
}

type TimedSegment added in v1.833.22

type TimedSegment struct {
	Id               int     `json:"id"`
	Seek             int     `json:"seek"`
	Start            float64 `json:"start"`
	End              float64 `json:"end"`
	Text             string  `json:"text"`
	Tokens           []int   `json:"tokens"`
	Temperature      float64 `json:"temperature"`
	AvgLogprob       float64 `json:"avg_logprob"`
	CompressionRatio float64 `json:"compression_ratio"`
	NoSpeechProb     float64 `json:"no_speech_prob"`
}

TimedSegment is one decoded span, and what the decoder thought of it.

type TimedWord added in v1.833.22

type TimedWord struct {
	Word  string  `json:"word"`
	Start float64 `json:"start"`
	End   float64 `json:"end"`
}

TimedWord is one word and when it was said. This is what a caption cuts on: without it a consumer has to place word boundaries by dividing a line's span by its letters, and the error compounds down the line.

type Timing added in v1.833.22

type Timing string

Timing is a timestamp granularity a caller may ask a transcription for. The two OpenAI defines, and the only two an upstream is asked for.

const (
	Word    Timing = "word"
	Segment Timing = "segment"
)

type Transcript added in v1.833.22

type Transcript struct {
	Text     string
	Words    []TimedWord
	Segments []TimedSegment
}

Transcript is what was heard — the text, and the timings the caller asked for. The text used to be the whole return, which is why no caption anywhere downstream could be timed to a word: the upstream measured every boundary and this plane had nowhere to put them.

Jump to

Keyboard shortcuts

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