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

audio

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Overview

Package audio owns speech controls, local audio history commands, voice creation, and transcript/speech response handling. Application assembly supplies request and presentation policy; media processing and storage remain in audiomedia and audiohistory.

Index

Constants

View Source
const LocalMetadata = "openai-local-audio"

LocalMetadata identifies local history commands that do not require API setup.

Variables

This section is empty.

Functions

func CaptureText

func CaptureText(request *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)

CaptureText retains successful transcript text as the SDK consumes its response.

func ConfigureLiveTranslation added in v1.40.3

func ConfigureLiveTranslation(root *cli.Command, policy TranslationOptions)

ConfigureLiveTranslation adds an explicit browser workflow to the file-translation route. The original action still owns every invocation without --live.

func ConfigureSpeech

func ConfigureSpeech(root *cli.Command, presentation func(context.Context, *cli.Command) SpeechPresentation)

ConfigureSpeech installs speech capture and interactive controls before generated dispatch.

func ConfigureText

func ConfigureText(root *cli.Command)

ConfigureText prepares capture because generated audio handlers parse their captured response as JSON even for text and subtitles. Retain those bytes while the SDK reads them, without changing generated code, the request, or the response consumed by the SDK.

func ConfigureVoices

func ConfigureVoices(root *cli.Command, policy VoiceOptions)

ConfigureVoices keeps voice validation and credential selection outside generated handlers. Install before command aliases and presentation wrappers.

func EmbedVoiceBody

func EmbedVoiceBody(cmd *cli.Command, bodyMap map[string]any, stdin *requestconfig.OnceStdinReader) (body map[string]any, err error)

EmbedVoiceBody resolves voice requirements before unrelated uploads can block or fail. Keep the type replay outside generic expansion and its partial-error cleanup.

func IsLocalCommand

func IsLocalCommand(command *cli.Command) bool

IsLocalCommand matches exact registered command nodes after descendant parsing; flag values and remote audio commands must never select this local path.

func IsVoiceAction

func IsVoiceAction(cmd *cli.Command) bool

IsVoiceAction reports whether voice preparation owns this command's request scope.

func PreflightVoiceBody

func PreflightVoiceBody(cmd *cli.Command, bodyMap map[string]any) error

PreflightVoiceBody checks known voice requirements before opening uploads. References and readers retain their context-aware inspection below; protected stdin stays literal.

func RegisterLocal

func RegisterLocal(root *cli.Command, options LocalOptions)

RegisterLocal installs local history and playback commands with application output policy.

func SkipFirstRunSetup

func SkipFirstRunSetup(root *cli.Command, args []string) bool

SkipFirstRunSetup classifies local audio paths synchronously from the current declarations. This does not parse values, invoke callbacks, cache nodes, or retain a command tree for the optional setup worker. Unrecognized prefixes keep the existing policy.

func TextResult

func TextResult(ctx context.Context, operation string, kind transformers.OutputKind) (string, bool)

TextResult selects captured text only for successful transcription and translation results.

func WriteSpeech

func WriteSpeech(response *http.Response, stdout io.Writer, outfile string) (bool, string, error)

WriteSpeech intercepts only this command's capture or SSE response on the shared download path. Ordinary audio keeps the existing binary response behavior. The caller owns response.Body, including closing it on every handled path.

Types

type AuthenticationGuidance added in v1.42.4

type AuthenticationGuidance struct {
	Summary, Action string
}

AuthenticationGuidance supplies a cause and short recovery steps.

type LocalOptions

type LocalOptions struct {
	ShowData      func(context.Context, *cli.Command, gjson.Result) error
	ReportReceipt func(*cli.Command, io.Writer, string, error) error
}

LocalOptions supplies application output policy; both callbacks are required.

type SpeechPresentation

type SpeechPresentation struct {
	Raw                    bool
	Render                 func(context.Context, io.Writer, jsonview.Iterator[clioutput.JSON]) error
	AuthenticationGuidance func(*cli.Command, *openai.Error) AuthenticationGuidance
}

SpeechPresentation supplies speech output and safe authentication guidance. Render receives the response context and owns formatted event presentation.

type TranslationOptions added in v1.40.3

type TranslationOptions struct {
	DefaultRequestOptions func(*cli.Command) []option.RequestOption
	RequestOptions        func(*cli.Command) ([]option.RequestOption, error)
}

TranslationOptions supplies the application's existing credential and transport policy.

type VoiceOptions

type VoiceOptions struct {
	DefaultRequestOptions func(*cli.Command) []option.RequestOption
	RequestOptions        func(*cli.Command) ([]option.RequestOption, error)
	ShowResponse          func(context.Context, *cli.Command, gjson.Result) error
}

VoiceOptions supplies application request/output policy; every callback is required.

type VoiceTypeError

type VoiceTypeError struct{}

VoiceTypeError reports unsupported voice discriminators without echoing values.

func (*VoiceTypeError) Error

func (e *VoiceTypeError) Error() string

Jump to

Keyboard shortcuts

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