speech

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RadioTransmissionUnknown    = iota
	RadioTransmissionContact    // Messages initiated by the pilot
	RadioTransmissionReadback   // Reading back an instruction
	RadioTransmissionUnexpected // Something urgent or unusual
)

Variables

View Source
var ErrTTSUnavailable = errors.New("TTS service unavailable")

Functions

func InitTTS

func InitTTS(l *log.Logger) error

func RequestTTS

func RequestTTS(voice Voice, text string, lg *log.Logger) (<-chan []byte, error)

RequestTTS requests synthesis of the provided text using the given voice. If successful, it returns a chan that provides the MP3 of the synthesized voice when it is available.

Types

type AircraftTypeSnippetFormatter

type AircraftTypeSnippetFormatter struct{}

func (AircraftTypeSnippetFormatter) Spoken

func (AircraftTypeSnippetFormatter) Validate

func (AircraftTypeSnippetFormatter) Validate(arg any) error

func (AircraftTypeSnippetFormatter) Written

type AirportSnippetFormatter

type AirportSnippetFormatter struct{}

func (AirportSnippetFormatter) Spoken

func (AirportSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (AirportSnippetFormatter) Validate

func (AirportSnippetFormatter) Validate(arg any) error

func (AirportSnippetFormatter) Written

func (AirportSnippetFormatter) Written(arg any) string

type AltRestrictionSnippetFormatter

type AltRestrictionSnippetFormatter struct{}

func (AltRestrictionSnippetFormatter) Spoken

func (AltRestrictionSnippetFormatter) Validate

func (AltRestrictionSnippetFormatter) Written

type AltSnippetFormatter

type AltSnippetFormatter struct{}

AltSnippetFormatter formats altitudes, which may be given as ints or float32s.

func (*AltSnippetFormatter) Spoken

func (a *AltSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (*AltSnippetFormatter) Validate

func (a *AltSnippetFormatter) Validate(arg any) error

func (*AltSnippetFormatter) Written

func (a *AltSnippetFormatter) Written(arg any) string

type AppControllerSnippetFormatter

type AppControllerSnippetFormatter struct{}

func (AppControllerSnippetFormatter) Spoken

func (AppControllerSnippetFormatter) Validate

func (AppControllerSnippetFormatter) Validate(arg any) error

func (AppControllerSnippetFormatter) Written

type ApproachSnippetFormatter

type ApproachSnippetFormatter struct{}

func (ApproachSnippetFormatter) Spoken

func (ApproachSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (ApproachSnippetFormatter) Validate

func (ApproachSnippetFormatter) Validate(arg any) error

func (ApproachSnippetFormatter) Written

func (ApproachSnippetFormatter) Written(arg any) string

type BasicNumberSnippetFormatter

type BasicNumberSnippetFormatter struct{}

func (BasicNumberSnippetFormatter) Spoken

func (BasicNumberSnippetFormatter) Validate

func (BasicNumberSnippetFormatter) Validate(arg any) error

func (BasicNumberSnippetFormatter) Written

func (BasicNumberSnippetFormatter) Written(arg any) string

type BeaconCodeSnippetFormatter

type BeaconCodeSnippetFormatter struct{}

func (BeaconCodeSnippetFormatter) Spoken

func (BeaconCodeSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (BeaconCodeSnippetFormatter) Validate

func (BeaconCodeSnippetFormatter) Validate(arg any) error

func (BeaconCodeSnippetFormatter) Written

func (BeaconCodeSnippetFormatter) Written(arg any) string

type CallsignSnippetFormatter

type CallsignSnippetFormatter struct{}

func (CallsignSnippetFormatter) Spoken

func (CallsignSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (CallsignSnippetFormatter) Validate

func (CallsignSnippetFormatter) Validate(arg any) error

func (CallsignSnippetFormatter) Written

func (CallsignSnippetFormatter) Written(arg any) string

type DepControllerSnippetFormatter

type DepControllerSnippetFormatter struct{}

func (DepControllerSnippetFormatter) Spoken

func (DepControllerSnippetFormatter) Validate

func (DepControllerSnippetFormatter) Validate(arg any) error

func (DepControllerSnippetFormatter) Written

type FixSnippetFormatter

type FixSnippetFormatter struct{}

func (FixSnippetFormatter) Spoken

func (f FixSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (FixSnippetFormatter) Validate

func (FixSnippetFormatter) Validate(arg any) error

func (FixSnippetFormatter) Written

func (FixSnippetFormatter) Written(arg any) string

type FrequencySnippetFormatter

type FrequencySnippetFormatter struct{}

func (FrequencySnippetFormatter) Spoken

func (FrequencySnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (FrequencySnippetFormatter) Validate

func (FrequencySnippetFormatter) Validate(arg any) error

func (FrequencySnippetFormatter) Written

func (FrequencySnippetFormatter) Written(arg any) string

type GroupFormSnippetFormatter

type GroupFormSnippetFormatter struct{}

func (GroupFormSnippetFormatter) Spoken

func (GroupFormSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (GroupFormSnippetFormatter) Validate

func (GroupFormSnippetFormatter) Validate(arg any) error

func (GroupFormSnippetFormatter) Written

func (GroupFormSnippetFormatter) Written(arg any) string

type HeadingSnippetFormatter

type HeadingSnippetFormatter struct{}

func (HeadingSnippetFormatter) Spoken

func (HeadingSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (HeadingSnippetFormatter) Validate

func (HeadingSnippetFormatter) Validate(arg any) error

func (HeadingSnippetFormatter) Written

func (HeadingSnippetFormatter) Written(arg any) string

type LetterSnippetFormatter

type LetterSnippetFormatter struct{}

func (LetterSnippetFormatter) Spoken

func (LetterSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (LetterSnippetFormatter) Validate

func (LetterSnippetFormatter) Validate(arg any) error

func (LetterSnippetFormatter) Written

func (LetterSnippetFormatter) Written(arg any) string

type PhraseFormatString

type PhraseFormatString string

PhraseFormatString is a string that potentially includes

func (PhraseFormatString) Spoken

func (s PhraseFormatString) Spoken(r *rand.Rand, args []any) string

func (PhraseFormatString) Validate

func (s PhraseFormatString) Validate(args []any, lg *log.Logger) bool

func (PhraseFormatString) Written

func (s PhraseFormatString) Written(r *rand.Rand, args []any) string

type RadioTransmission

type RadioTransmission struct {
	Strings    []PhraseFormatString
	Args       [][]any // each slice contains values passed to the corresponding PhraseFormatString
	Controller string
	Type       RadioTransmissionType
}

RadioTransmission holds components that together represent a single radio transmission by a pilot; they may be built up from multiple instructions provided in a single controller command.

func MakeContactTransmission

func MakeContactTransmission(s string, args ...any) *RadioTransmission

MakeContactRadioTransmission is a helper function to make a pilot transmission for initial contact from a single formatting string and set of arguments.

func MakeReadbackTransmission

func MakeReadbackTransmission(s string, args ...any) *RadioTransmission

MakeReadbackTransmission is a helper function to make a pilot transmission of a readback from a single formatting string and set of arguments.

func MakeUnexpectedTransmission

func MakeUnexpectedTransmission(s string, args ...any) *RadioTransmission

MakeUnexpectedTransmission similarly makes a single pilot transmission from the provided format string and arguments, but also marks the transmission as unexpected.

func (*RadioTransmission) Add

func (rt *RadioTransmission) Add(s string, args ...any)

Add is a convenience function to add a transmission snippet to the RadioTransmission. It's more or less equivalent to calling Merge(MakeRadioTransmission(...)).

func (*RadioTransmission) Merge

func (rt *RadioTransmission) Merge(r *RadioTransmission)

Merge takes a separately-constructed RadioTransmission and merges its contents with the current one.

func (RadioTransmission) Spoken

func (rt RadioTransmission) Spoken(r *rand.Rand) string

Spoken returns a string corresponding to how the transmission should be spoken, which appropriate phonetic substitutions made (e.g. "9" -> "niner").

func (*RadioTransmission) Validate

func (rt *RadioTransmission) Validate(lg *log.Logger)

Validate ensures that the types of arguments match with the formatting directives in the PhraseFormatStrings; errors are logged to the provided logger.

func (RadioTransmission) Written

func (rt RadioTransmission) Written(r *rand.Rand) string

Written returns a string corresponding to how the transmission should be displayed as text on the screen.

type RadioTransmissionType

type RadioTransmissionType int

func (RadioTransmissionType) String

func (r RadioTransmissionType) String() string

type SIDSnippetFormatter

type SIDSnippetFormatter struct{}

func (SIDSnippetFormatter) Spoken

func (SIDSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (SIDSnippetFormatter) Validate

func (SIDSnippetFormatter) Validate(arg any) error

func (SIDSnippetFormatter) Written

func (s SIDSnippetFormatter) Written(arg any) string

type STARSnippetFormatter

type STARSnippetFormatter struct{}

func (STARSnippetFormatter) Spoken

func (STARSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (STARSnippetFormatter) Validate

func (STARSnippetFormatter) Validate(arg any) error

func (STARSnippetFormatter) Written

func (s STARSnippetFormatter) Written(arg any) string

type SnippetFormatter

type SnippetFormatter interface {
	// Written
	Written(arg any) string
	Spoken(r *rand.Rand, arg any) string
	Validate(arg any) error
}

SnippetFormatter defines an interface for formatting short text snippets corresponding to various aviation-related concepts into both speech and text. Each is takes a single value specifying the value of the corresponding thing (altitude, speed, etc.)

type SpeedSnippetFormatter

type SpeedSnippetFormatter struct{}

func (SpeedSnippetFormatter) Spoken

func (SpeedSnippetFormatter) Spoken(r *rand.Rand, arg any) string

func (SpeedSnippetFormatter) Validate

func (SpeedSnippetFormatter) Validate(arg any) error

func (SpeedSnippetFormatter) Written

func (SpeedSnippetFormatter) Written(arg any) string

type TTSRequest

type TTSRequest struct {
	Model string  `json:"model"`
	Input string  `json:"input"`
	Voice string  `json:"voice"`
	Speed float64 `json:"speed"` // tts-1 and tts-1-hd only
	//Instructions string  `json:"instructions"`  // gpt-4o-mini-tts only
	Format string `json:"response_format"`
}

type Voice

type Voice string

func GetRandomVoice

func GetRandomVoice() (Voice, error)

Jump to

Keyboard shortcuts

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