Documentation
¶
Overview ¶
Speech: the voices that read text aloud, the recognizers that turn speech into text and the engines that hear a wake word, each a plugin, with the pipelines every surface shares around them
Index ¶
- Constants
- Variables
- func Absent(message string) error
- func Base64(text string) ([]byte, error)
- func Base64Std(text string) ([]byte, error)
- func Body(response *http.Response, label string, limit int) ([]byte, error)
- func Chosen(cfg *config.Config, key string) string
- func Chunks(body io.ReadCloser, size int, fill bool) iter.Seq2[[]byte, error]
- func Client(env httpx.Env, timeout time.Duration) *http.Client
- func Container(head []byte) string
- func Decoded(data []byte) string
- func Detail(captured *terminal.Captured, err error) string
- func Echo(transcript, spoken string) bool
- func Failed(response *http.Response) error
- func Field(event map[string]any, key string) string
- func Flag(event map[string]any, key string) bool
- func Form(parts []Part) ([]byte, string, error)
- func Hallucination(transcript string) bool
- func Held(value any) bool
- func IsConfig(err error) bool
- func Key(section, name string) string
- func Kind(value any) string
- func MediaType(path string) string
- func Misconfigured(message string) error
- func Normal(name string) string
- func Number(value any) float64
- func Object(response *http.Response, label string) (map[string]any, error)
- func PCMBytes(in []int16) []byte
- func PostJSON(ctx context.Context, env httpx.Env, url string, payload any, ...) (*http.Response, error)
- func Prefix(text string, n int) string
- func PromptIgnored(label string)
- func Raised(kind, message string) error
- func Render(template string, values map[string]string) string
- func ResponseFormat(path string) string
- func Run(ctx context.Context, argv []string, timeout time.Duration, env []string) (*terminal.Captured, error)
- func Save(response *http.Response, path, label string) (string, error)
- func Seconds(value any, unit time.Duration) float64
- func Send(ctx context.Context, env httpx.Env, method, url string, body []byte, ...) (*http.Response, error)
- func SocketURL(base, suffix, query string) string
- func Split(text string, limit int) []string
- func Spoken(text string, limit int) string
- func StopPhrase(phrases []string, transcript string) bool
- func StopPhrases(cfg *config.Config) []string
- func TagRules(extra string) string
- func Text(value any) string
- func Transcribed(path, via, model string, text string)
- func TranscriptOf(reply any) (string, error)
- func Upload(ctx context.Context, env httpx.Env, url string, parts []Part, ...) (*http.Response, error)
- func VoiceNoteType(format string) string
- func WAV(pcm []byte, rate, channels, width int) []byte
- func WAVPath(output string) string
- func WakePhrase(cfg *config.Config) string
- func WhisperLanguage(language string, supported []string) string
- func WhisperModel(model string) string
- type APIError
- type AbsentError
- type Asset
- type Call
- type Catalog
- type Chats
- type Choices
- type Chunker
- type ConfigError
- type ConnectionError
- type Delivery
- type DependencyError
- type Endpointed
- type Engine
- type ExitError
- type Fed
- type Feeder
- type Hearing
- type Hindrance
- type Hints
- type Hotword
- type Job
- func (j *Job) AbsentPrograms(programs []string) []Program
- func (j *Job) AudioCache() string
- func (j *Job) Automatic(ctx context.Context) (Recognizer, Standing, bool)
- func (j *Job) CanSpeak() bool
- func (j *Job) Compact(ctx context.Context, path, work string) (string, string)
- func (j *Job) Duration(ctx context.Context, path string) (float64, bool)
- func (j *Job) Environ(extra map[string]string) []string
- func (j *Job) FFmpeg(ctx context.Context) string
- func (j *Job) FFprobe(ctx context.Context) string
- func (j *Job) Float(key string) float64
- func (j *Job) For(ctx context.Context) *Job
- func (j *Job) FromWAV(ctx context.Context, wav, output string) (string, error)
- func (j *Job) Getenv(name string) string
- func (j *Job) Helper(ctx context.Context, extra string, args []string, timeout time.Duration) (string, string, int, error)
- func (j *Job) Key(variable string, kinds ...string) string
- func (j *Job) Limit(voice Voice) int
- func (j *Job) Listen(ctx context.Context, partial func(string)) (Live, string, error)
- func (j *Job) Missing(ctx context.Context, r Recognizer) string
- func (j *Job) OpenAIKey() string
- func (j *Job) OpenAITranscribe(ctx context.Context, r Recognizer, client OpenAI, path, model string, ...) Transcript
- func (j *Job) Opus(ctx context.Context, source, output string) string
- func (j *Job) Passed(names []string) map[string]string
- func (j *Job) Provider(kind string) string
- func (j *Job) Provisioned(extra string) bool
- func (j *Job) Python(extra string) (string, error)
- func (j *Job) Ready(v Voice) bool
- func (j *Job) Recognition(ctx context.Context) Recognition
- func (j *Job) RecognizerStanding(ctx context.Context, r Recognizer) Standing
- func (j *Job) Recognizing(ctx context.Context) string
- func (j *Job) Recording(ctx context.Context, path string) Transcript
- func (j *Job) RenewXAI(ctx context.Context) error
- func (j *Job) Scratch() string
- func (j *Job) Seconds(key string, unit time.Duration) float64
- func (j *Job) Settle(t Transcript) Transcript
- func (j *Job) Shell(ctx context.Context, command string, timeout time.Duration, ...) (string, string, error)
- func (j *Job) SilkToWAV(ctx context.Context, source, output string, rate int) error
- func (j *Job) Speak(ctx context.Context, text string, live bool, sink Sink) error
- func (j *Job) Speaker() Voice
- func (j *Job) Speaking() Speaking
- func (j *Job) Speed(request Request, own string) (float64, bool)
- func (j *Job) Streams() bool
- func (j *Job) Tagged(ctx context.Context, system, prompt, fallback, label, instead string, ...) string
- func (j *Job) Text(key, fallback string) string
- func (j *Job) TextToSpeech(ctx context.Context, call Call) Outcome
- func (j *Job) Transcribe(ctx context.Context, path, model, source string) Transcript
- func (j *Job) Unsupported(extra string) string
- func (j *Job) VoiceNote(ctx context.Context, source, format string) (string, bool)
- func (j *Job) VoiceStanding(v Voice) Standing
- func (j *Job) Which(name string) string
- func (j *Job) Worker(extra, script string, env map[string]string) (*Worker, error)
- func (j *Job) WriteWAV(ctx context.Context, wav []byte, output string) (string, error)
- func (j *Job) XAI(preferKey bool) (web.XAI, bool)
- type Lack
- type Limit
- type Live
- type Matcher
- type Model
- type OpenAI
- func (c OpenAI) Speak(ctx context.Context, r SpeechRequest) error
- func (c OpenAI) Speech(ctx context.Context, body map[string]any, headers map[string]string, ...) error
- func (c OpenAI) SpeechStream(ctx context.Context, body map[string]any, headers map[string]string) (*http.Response, error)
- func (c OpenAI) Transcription(ctx context.Context, path string, fields [][2]string) (any, error)
- type Opus
- type Outcome
- type PCM
- type Page
- type Part
- type Persona
- type Phrase
- type Pick
- type Picker
- type Pieces
- type Placeholder
- type Profiles
- type Program
- type Programs
- func (p Programs) Add(cfg *config.Config, name, command string) error
- func (p Programs) Change(cfg *config.Config, name, field string, value any) error
- func (p Programs) Command(command string) error
- func (p Programs) Guard() config.Guard
- func (p Programs) Key(cfg *config.Config, name string) string
- func (p Programs) Name(cfg *config.Config, name, old string) error
- func (p Programs) Remove(cfg *config.Config, name string) (bool, error)
- func (p Programs) Rename(cfg *config.Config, name, to string) (bool, error)
- type Recognition
- type Recognizer
- func (r Recognizer) CloudFailure(err error, path, label, detail string) Transcript
- func (r Recognizer) Failure(message string) Transcript
- func (r Recognizer) Heard(text string) Transcript
- func (r Recognizer) OpenAIFailure(err error, path, label string) Transcript
- func (r Recognizer) Replied(response *http.Response, err error, path, label string, ...) (Transcript, map[string]any)
- type Registrant
- type Registry
- func (r *Registry) Engine(cfg *config.Config, name string) (Engine, bool)
- func (r *Registry) Engines(cfg *config.Config) []Engine
- func (r *Registry) Host() *Speech
- func (r *Registry) Recognizer(cfg *config.Config, name string) (Recognizer, bool)
- func (r *Registry) Recognizers(cfg *config.Config) []Recognizer
- func (r *Registry) Register(registrant Registrant)
- func (r *Registry) Voice(cfg *config.Config, name string) (Voice, bool)
- func (r *Registry) Voices(cfg *config.Config) []Voice
- func (r *Registry) WakeEngine(cfg *config.Config, provider string, model bool) (Engine, bool)
- type ReplyError
- type Request
- type Resampler
- type Resident
- type Search
- type Services
- type Session
- type Setup
- type Sink
- type Socket
- type Speaking
- type Speech
- func (s *Speech) Acquire(ctx context.Context, job *Job, lease string)
- func (s *Speech) Assets() string
- func (s *Speech) Dir() string
- func (s *Speech) Drop(ctx context.Context, job *Job, lease string)
- func (s *Speech) Fetched(a Asset) bool
- func (s *Speech) File(ctx context.Context, env httpx.Env, a Asset) (string, error)
- func (s *Speech) Job(cfg *config.Config) *Job
- func (s *Speech) Local() *Job
- func (s *Speech) Packages() *packages.Packages
- func (s *Speech) Profile(name string) (*config.Config, error)
- func (s *Speech) Reading(cfg *config.Config) *Job
- func (s *Speech) RecognitionPrograms() Programs
- func (s *Speech) Register(registrant Registrant)
- func (s *Speech) SpeechPrograms() Programs
- func (s *Speech) Tree(ctx context.Context, env httpx.Env, a Asset) (string, error)
- type SpeechRequest
- type Standing
- type StatusError
- type Stream
- type TimeoutError
- type Transcript
- type Voice
- type Wake
- type Wave
- type Wire
- type Words
- type Worker
Constants ¶
const ( ListenHeard = "heard" ListenCancelled = "cancelled" ListenFailed = "failed" ListenTimeout = "timeout" )
How a fed live transcription ended: its final transcript heard, cancelled, failed, or out of time
const ( InUse = "In use" Ready = "Ready" Free = "Free" NotInstalled = "Not installed" NeedsKey = "Needs an API key" NeedsSignIn = "Needs a sign-in" CantRun = "Can't run here" )
State words of a service, the same on every page and in every sentence; Needs and a program, such as Needs espeak-ng, besides
const Agent = "icebath/speech"
Agent every service of speech is told
const BodyCap = 16 << 20
Largest reply body a speech service may send
const FinishTimeout = 20.0
Seconds a live session waits for its final transcript once the audio ends
const LiveRate = 16000
Rate live sessions are fed at
const None = "none"
Name the recognizer in use takes when none can transcribe
const OpenAIAudioKey = "VOICE_TOOLS_OPENAI_KEY"
Variable OpenAI's audio services prefer over the general OpenAI key, kept apart from routers that take OPENAI_API_KEY
const OpenAIBase = "https://api.openai.com/v1"
Address of OpenAI's API, where an audio client goes when given none
const ShortEspeak = `` /* 563-byte string literal not displayed */
Python of a local engine that moves eSpeak NG data under a short path, as its C library fails on data paths of 160 bytes or more
const UploadCap = 25 << 20
Largest upload of the cloud services that state none of their own
const WakeRate = 16000
Sample rate every wake engine hears, 16 kHz mono 16 bit
Variables ¶
var Fires = []hooks.Site{ {Point: hooks.PreTranscription, By: "speech", When: "before a recording is turned into text"}, }
The moments of speech the hook points hear of, which the hooks screen and Doctor say of each point
var WhisperModels = []string{"base", "tiny", "small", "medium", "large-v3", "turbo"}
Sizes of the Whisper model a local engine runs, the first the default
Functions ¶
func Base64 ¶
Bytes of base64 text in the standard or the URL alphabet, white space skipped and the padding optional, as services send audio
func Base64Std ¶
Bytes of base64 text in the standard alphabet read leniently: any other character dropped and the padding made whole after its first sign; text cut short of a whole quantum refused
func Chunks ¶
Pieces of a reply body as they arrive, at most size bytes each and exactly size when filled but for the last, the body closed after
func Client ¶
Client through the proxy and authorities of the environment, the profile's, none meaning no proxy and the system's authorities, whose connect, TLS and first byte each get the timeout
func Decoded ¶
Text of a command's output decoded as the whisper programs write it, a byte order mark dropped
func Detail ¶
What a failed helper said, its error output first, then its output, else the error itself
func Echo ¶
Whether a transcript reads as the speaker's own sound picked up again: alike with what was spoken as a whole, or with a stretch of it
func Hallucination ¶
Whether a transcript is empty or what Whisper is known to hear in silence
func Held ¶
Whether a JSON value holds something: not null, false, zero, empty text, an empty list or an empty object
func MediaType ¶
Media type of a file by its extension, this machine's table for those speech has none of, application/octet-stream when unknown
func PostJSON ¶
func PostJSON(ctx context.Context, env httpx.Env, url string, payload any, headers map[string]string) (*http.Response, error)
A JSON body posted through the proxy and authorities of the environment, the profile's, with a 60 second bound on each phase
func Prefix ¶
First n characters of text, any bytes that are no text shown as �, such as of the body of a failed reply
func PromptIgnored ¶
func PromptIgnored(label string)
Line kept of a log of what a prompt did, the backend ignoring prompts
func Raised ¶
Failure a Python engine answered, read by the kind of error it raised: a bad value a configuration error, a missing file a missing dependency
func Render ¶
A command template with each {name} or {{name}} placeholder put in quoted for where it sits, ${name} left to the shell, and the other doubled braces made single
func ResponseFormat ¶
Format of an OpenAI style speech reply the path's extension asks for: opus for .ogg, wav, flac, else mp3
func Run ¶
func Run(ctx context.Context, argv []string, timeout time.Duration, env []string) (*terminal.Captured, error)
Runs a helper program with its output captured in the environment given, such as a job's Environ, this machine's variables alone when nil as Capture takes them: an error naming it for a failure, a non-zero exit or a time out
func Seconds ¶
Seconds a length of time holds: a number counts the unit, text such as 500ms or 2m is read as a length
func Send ¶
func Send(ctx context.Context, env httpx.Env, method, url string, body []byte, headers map[string]string, timeout time.Duration) (*http.Response, error)
A request sent with the headers through the proxy and authorities of the environment, the profile's, its connect, first byte and every quiet stretch of its body each bounded by the timeout
func Split ¶
Splits text under the cap at sentence punctuation, an over long sentence at its words and then hard, nothing dropped but repeated space
func Spoken ¶
Spoken script of text an assistant wrote: reasoning blocks, markdown, symbols, identifiers and layout turned into what a voice reads well, cut to limit characters when the limit is positive
func StopPhrase ¶
Whether the whole utterance, its punctuation trimmed, is one of the stop phrases
func StopPhrases ¶
Stop phrases of a profile, lower case with blanks dropped
func Transcribed ¶
Log line of a transcription
func TranscriptOf ¶
Plain transcript of a reply that is text, an object with text, or another value; an object without text fails with its error
func Upload ¶
func Upload(ctx context.Context, env httpx.Env, url string, parts []Part, headers map[string]string, timeout time.Duration) (*http.Response, error)
A multipart upload through the proxy and authorities of the environment, the profile's, with a bound on each phase
func VoiceNoteType ¶
Media type of the kind of voice message whose files end so, empty for a kind ffmpeg makes none of
func WakePhrase ¶
The wake phrase in effect for the profile, the one every page, message and listener says: its own, else hey and the profile's name while each profile has its own phrase, the profile icebath starts with keeping hey icebath, else hey icebath
func WhisperLanguage ¶
Whisper code of a language hint such as en-US, empty with a warning when it is not a code, or not one of those supported when they are known
func WhisperModel ¶
Model a local Whisper engine runs: base for none, and for a cloud only name with a warning
Types ¶
type AbsentError ¶
type AbsentError struct{ Message string }
A local engine is not installed: its text is the whole answer, with the way to install it
func (*AbsentError) Error ¶
func (e *AbsentError) Error() string
type Call ¶
type Call struct {
Text string
OutputPath string
// Speed asked for, nil for none
Speed *float64
Instructions string
// Voice of the call, for a voice that lets the model pick
Voice string
// The text is speech text already, as Spoken gives it, and is read as it is
Speech bool
}
What one text_to_speech call asks
type Catalog ¶
type Catalog struct {
// Setting that keeps the voice a person picked
Setting string
// The model may pick a voice for each call
Picks bool
// What the voices are of, as the model is told it, such as Narrator of the extension acme
Title string
// One page of the voices a search finds
Find func(ctx context.Context, job *Job, search Search) (Page, error)
}
Voices a voice speaks with, one catalog the host offers twice: as the list a person picks the voice its setting keeps from on its page in Voice, and to the model, which may pick one for each call with voice_id after it searched them with find_voices
type Chats ¶
type Chats interface {
// The chat apps of the profile of the settings as choices, by the name the sessions of each record as their source
ChatApps(cfg *config.Config) []config.Option
// How the names of the files the app of the name plays as voice messages end, such as ogg, m4a or amr; empty for an app that says
// none
VoiceFormat(cfg *config.Config, app string) string
}
Registrant that connects chat apps, which says which apps there are and the kind of file each plays as a voice message: the settings of speech name every app where they keep something for each, and what is read aloud for an app is made a voice message it plays
type Choices ¶
type Choices struct {
Setting string
// Values in the order offered, the setting's own value among them or not; none, with why, when they can't be listed now
List func(ctx context.Context, job *Job) ([]Pick, error)
}
Values a person may pick for one setting of a service on its page in Voice, listed when the list is opened
type Chunker ¶
type Chunker struct {
Least int
// contains filtered or unexported fields
}
Reads a streamed reply out as speech text a sentence at a time, sentences shorter than the least merged into the next. The reply is never cleaned piece by piece: each time a sentence may have ended, the whole reply so far is cleaned as Spoken cleans it, to its last space, and the sentences that cleaning completes beyond what was handed out are handed out, a sentence once the word after it came, since only that word settles how it ends. A span of markup the cut falls inside is taken out as Spoken takes out one that never closes, so no markup is read whatever the cut, and the speech of a reply streamed in pieces is the speech Spoken gives the whole reply, cut at the same places
func NewChunker ¶
type ConfigError ¶
type ConfigError struct{ Message string }
Settings or credentials keep a service from running: its text tells the person what to set
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type ConnectionError ¶
A connection to the API that broke, or a try that ran out of time
func (*ConnectionError) Error ¶
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶
func (e *ConnectionError) Unwrap() error
type Delivery ¶
type Delivery struct {
Platform string `json:"platform"`
MaxFileBytes int `json:"max_file_bytes"`
SafetyRatio float64 `json:"-"`
TargetBytes int `json:"target_file_bytes"`
}
Upload limits of the chat app speech goes to
type DependencyError ¶
type DependencyError struct{ Message string }
Something a service needs on this machine is missing, such as a file a local engine reads
func (*DependencyError) Error ¶
func (e *DependencyError) Error() string
type Endpointed ¶
type Endpointed interface {
Live
Ended() <-chan struct{}
}
A live session whose recognizer hears where the speaker stopped, which ends a recording there rather than at the silence the microphone hears; a recognizer that does not leaves the end to the recording. Ended is closed once it heard the speaker stop
type Engine ¶
type Engine struct {
// As wake_word.provider names it, and the other names that pick it
Name string
Aliases []string
Title string
About string
// Place in the automatic choice when a model file is set, lower first
Rank int
// Detects any phrase, so it is the automatic choice when no model file is set
Open bool
// Python set whose native library it runs, empty for one that runs on icebath's own speech engine
Extra string
// Whether this machine has a build of it at all
Supported func(s *Speech) bool
// Whether what it runs is installed now with its settings by key, never installing anything
Installed func(s *Speech, settings map[string]string) bool
// Downloads what it runs onto this computer, saying each step, for an engine whose install is a download rather than a Python set;
// what it would otherwise fetch the first time it listens
Fetch func(ctx context.Context, wake *Wake, say func(step string)) error
// Setting of the model file it needs set, empty for an engine that needs none
Model string
// Needs the Picovoice access key of the profile's environment
Key bool
// Builds the detector of the wake settings
New func(ctx context.Context, wake *Wake) (Hotword, error)
}
An engine that hears a wake word, what a speech plugin registers; it runs where the microphone is
type ExitError ¶
A program of yours that exited with a failure
type Fed ¶
type Fed struct {
// contains filtered or unexported fields
}
A live transcription fed to a recognizer that hears in feeds, such as one of an extension: the audio sent in order on one worker, all that came while a feed was out going in the next, so a slow recognizer gets larger feeds and never two at once; the partial text the final words so far and the interim ones after them; the end of the speech said where the recognizer hears it
func Feeding ¶
func Feeding(ctx context.Context, provider string, partial func(string), feed Feeder, abandon func()) *Fed
Live transcription of the recognizer named provider fed through feed, its partial text handed to partial as it changes; abandon, when given, is told once it is given up. Its worker starts at once on a context of its own, the caller's own ending none of it
func (*Fed) Ended ¶
func (f *Fed) Ended() <-chan struct{}
Closed once the recognizer heard the speaker stop, which ends a recording there rather than at the silence the microphone hears
func (*Fed) Finish ¶
func (f *Fed) Finish(timeout float64) Transcript
Ends the audio and waits for the final transcript, giving the transcription up after the seconds
type Feeder ¶
Hands a recognizer the audio of a live transcription in order, one feed at a time: the audio spoken since the last feed, and whether the audio ended, a feed of none after the end asking for what is left; answered with what it heard since
type Hearing ¶
What one feed of a live transcription heard: the words since the last feed, each interim one replacing the interim words before it and each final one kept; whether the recognizer heard the speaker stop; and once it finished after the end of the audio, the whole text it heard, empty to take the final words, and whether nothing was said
type Hindrance ¶
type Hindrance struct {
// A clause, such as Local Whisper is not installed
Cause string
Lack Lack
// Service it is about, empty for none in particular
Service string
// Command that installs the program of the system it lacks
Install string
}
What keeps a part of voice from working: what is wrong in a person's words, and the kind of thing that fixes it
type Hotword ¶
type Hotword interface {
FrameLength() int
// Whether the frame completes the wake word
Process(frame []int16) (bool, error)
// Forgets what it heard, so audio from before a pause cannot fire
Reset() error
Close()
}
Hotword detector over 16 kHz frames
type Job ¶
type Job struct {
Speech *Speech
Config *config.Config
// Helper models, for the tags some voices add to text; those of the profile when the job runs in no session
Aux *auxiliary.Client
// Surface the speech is delivered on, such as telegram, which takes Ogg Opus voice bubbles; empty for this machine
Platform string
// Why a file the job is asked to write, or to read, may not be touched, such as a credential store; nil where nothing guards paths
Unwritable, Unreadable func(path string) string
// contains filtered or unexported fields
}
What one piece of speech work is done for: the profile, its helper models and the surface the result goes to
func (*Job) AbsentPrograms ¶
Programs among those named that the search path of the profile's environment lacks, each with the command that installs it
func (*Job) AudioCache ¶
Folder generated speech is kept in, the profile's audio cache
func (*Job) Automatic ¶
Recognizer Automatic stands for now: the first that is ready of the local engines and then the cloud services, by their rank
func (*Job) CanSpeak ¶
Whether the voice the profile speaks with can run now, never installing anything; a name no voice has can't
func (*Job) Environ ¶
Environment of a program speech runs for the profile: its own, without the credentials programs may not see, extra on top
func (*Job) For ¶
The job, for the request of the context given: its calls renew a sign-in under that context
func (*Job) FromWAV ¶
Moves the WAV an engine wrote into the requested container, converted with ffmpeg, renamed as it is without one
func (*Job) Getenv ¶
Variable of the profile's environment: its own, its .env, its secret stores, then this process's
func (*Job) Helper ¶
func (j *Job) Helper(ctx context.Context, extra string, args []string, timeout time.Duration) (string, string, int, error)
Runs a helper script in the interpreter of a provisioned Python set to its end within the timeout, its output captured
func (*Job) Key ¶
Key of a service: the variable of the profile's environment, else the account of a provider of a kind the profile connected
func (*Job) Limit ¶
Characters one request to a voice takes: its own setting, then what the voice says, else 4000
func (*Job) Listen ¶
Live transcription session of the recognizer in use, nil when stt.streaming is off or it transcribes whole files only
func (*Job) Missing ¶
func (j *Job) Missing(ctx context.Context, r Recognizer) string
Why the recognizer can't transcribe with the profile's settings now, empty when it can
func (*Job) OpenAIKey ¶
Key of OpenAI's speech and transcription: the voice key, then the OpenAI key or account
func (*Job) OpenAITranscribe ¶
func (j *Job) OpenAITranscribe(ctx context.Context, r Recognizer, client OpenAI, path, model string, hints Hints, label string) Transcript
Transcribes through an OpenAI style transcriptions API with the language and prompt hinted; a file the API refuses as unsupported, corrupted or invalid, or that a failing service could not take, is sent once more transcoded to compact m4a
func (*Job) Opus ¶
Encodes audio ffmpeg reads into voip tuned Ogg Opus at the path, in place when it is the source; empty when ffmpeg is missing or fails
func (*Job) Provider ¶
Provider of the profile of a kind, by its name in the profile; empty while the profile has none. A reading looks each kind up once
func (*Job) Provisioned ¶
Whether a provisioned Python set is there, looked up once by a reading
func (*Job) Python ¶
Interpreter of a provisioned Python set of a local engine, the refusal saying where to install it when it is not installed
func (*Job) Recognition ¶
func (j *Job) Recognition(ctx context.Context) Recognition
The one answer to which recognizer turns the profile's speech into text and what keeps it from it: speech to text switched off, the service chosen and what it lacks, or none chosen and none ready. A chosen service that can't run stays the one named, so what it lacks is what is said
func (*Job) RecognizerStanding ¶
func (j *Job) RecognizerStanding(ctx context.Context, r Recognizer) Standing
How the recognizer stands for the profile, asked once by a reading
func (*Job) Recognizing ¶
Recognizer that transcribes now, None while something keeps speech from being turned into text
func (*Job) Recording ¶
func (j *Job) Recording(ctx context.Context, path string) Transcript
Transcription of a voice recording, a known hallucination on silence read as nothing said unless it is a stop phrase
func (*Job) Scratch ¶
Folder the job's passing files go in, such as a recording a window sent to be transcribed or speech on its way to a file: the profile's scratch folder, where its commands' TMPDIR points, so those of one profile never sit where another's do; empty, the system's own, when it can't be made
func (*Job) Seconds ¶
Seconds a setting kept as a plain number holds: its number counts the unit, text such as 500ms or 2m is read as a length. A setting declared a length of time is read with Config.GetDuration, by its own unit
func (*Job) Settle ¶
func (j *Job) Settle(t Transcript) Transcript
A recording's transcript with what Whisper hears in silence read as nothing said, a stop phrase kept
func (*Job) Shell ¶
func (j *Job) Shell(ctx context.Context, command string, timeout time.Duration, passthrough []string, purpose string) (string, string, error)
Runs a command line of yours through the shell, in a group of its own that dies with icebath, without the credentials programs may not see but with the variables it passes through; its whole tree killed once it writes nothing for the timeout
func (*Job) SilkToWAV ¶
Decodes a SILK voice note of QQ or WeChat to WAV at the sample rate with pilk
func (*Job) Speak ¶
Speaks one sentence of speech text for the app to play: as PCM while it is made when asked and a voice streams, else as the files text_to_speech writes, each sent as a clip and removed. The app cleaned the sentence with the whole of its reply, as Spoken does, so it is read as it is: cleaning a sentence alone again would read it unlike the reply it was cut from
func (*Job) Speaking ¶
The one answer to which voice reads the profile's replies aloud and what keeps it from it: a name no voice has, or what the voice lacks
func (*Job) Speed ¶
Speed returns the call's speed, else the service's speed setting, else tts.speed.
func (*Job) Tagged ¶
func (j *Job) Tagged(ctx context.Context, system, prompt, fallback, label, instead string, level zerolog.Level) string
Text of a voice rewritten by the speech tags model under the system prompt, the fallback when the call fails or comes back empty; a failure is logged at the level given
func (*Job) TextToSpeech ¶
Speaks text into audio files for the model and the chat apps: text cleaned for speech and split under the voice's limit, each piece written, the files packed under the platform's upload limit and named by the media tag
func (*Job) Transcribe ¶
func (j *Job) Transcribe(ctx context.Context, path, model, source string) Transcript
Transcribes an audio file with the recognizer in use: the file checked, a SILK note decoded, Apple's CAF converted for a cloud service, silence trimmed before an upload and a file too large for one request split at its pauses
func (*Job) Unsupported ¶
Why a Python set can't run on this computer, empty when it can or no feature declares it; looked up once by a reading
func (*Job) VoiceNote ¶
The recording as a file of the kind a chat app plays as a voice message, the kind named by how such a file ends: the file itself when it holds that already, else one made of it in the job's scratch folder, which is the caller's to delete. False where ffmpeg makes none of the kind, is missing, or fails
func (*Job) VoiceStanding ¶
How the voice stands for the profile, asked once by a reading
func (*Job) Which ¶
Program of the name on the search path of the profile's environment, the one its programs run with; empty when there is none. A reading looks each name up once, on the search path it read once
func (*Job) Worker ¶
Starts the script in the interpreter of a provisioned Python set, its error output logged, with the variables given over the profile's
type Lack ¶
type Lack int
Kind of thing that fixes what keeps a part of voice from working
const ( // Nothing a page of Voice does LacksNothing Lack = iota // Its Python set, which its page installs LacksInstall // An API key, which its page takes LacksKey // A sign-in at a provider LacksSignIn // A program of the system, which Install says how to install LacksProgram // A build for this computer, so another service is needed LacksBuild // A setting of its own, set on its page LacksSetup // The switch that turns it on LacksSwitch // A service: the one chosen does not exist, or none is chosen and none is ready LacksService )
type Live ¶
type Live interface {
Push(pcm []byte)
// Ends the audio and waits for the final transcript, giving up after the seconds
Finish(timeout float64) Transcript
Cancel()
}
One live transcription session: 16 kHz mono PCM in, partial text out through the callback it was opened with, the final transcript once the audio ends
type OpenAI ¶
type OpenAI struct {
Key string
BaseURL string
// Tries after the first, and the limit of each try
Retries int
Timeout time.Duration
// Environment of the profile the requests are for, which names their proxy and the authorities they trust: no proxy and the system's
// authorities alone when nil
Env httpx.Env
// Headers every request carries under those of the call, such as OpenAI-Project
Headers map[string]string
}
Audio endpoints of OpenAI and the services that copy them, such as Groq and DeepInfra, tried again as OpenAI's SDK tries
func SpeechClient ¶
Speech client of the profile's environment as OpenAI's SDK makes one: two tries after the first, ten minutes each
func (OpenAI) Speak ¶
func (c OpenAI) Speak(ctx context.Context, r SpeechRequest) error
Writes the speech of the request to its path
func (OpenAI) Speech ¶
func (c OpenAI) Speech(ctx context.Context, body map[string]any, headers map[string]string, path string) error
Writes the speech of a body POSTed to audio/speech to the path
type Opus ¶
type Opus int
How a voice gives Ogg Opus
const ( // Gives none, its files sent as plain attachments NoOpus Opus = iota // Writes Ogg Opus itself when asked for an .ogg path NativeOpus // Its files are transcoded to Ogg Opus with ffmpeg where the platform shows voice bubbles TranscodedOpus // Opted in to voice bubbles, its files always transcoded to Ogg Opus, such as a program of yours marked voice_compatible OptedOpus )
type Outcome ¶
type Outcome struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
FilePath string `json:"file_path"`
FilePaths []string `json:"file_paths"`
MediaTag string `json:"media_tag"`
Provider string `json:"provider"`
VoiceCompatible bool `json:"voice_compatible"`
ChunkCount int `json:"chunk_count"`
DeliveryFiles int `json:"delivery_file_count"`
CombinedChunks bool `json:"combined_chunks"`
DeliveryProfile *Delivery `json:"delivery_profile"`
// contains filtered or unexported fields
}
Result of a speech synthesis, as the model reads it when it succeeded
type Page ¶
One page of a catalog: its voices, the cursor of the next page, empty after the last, and how many voices the search finds in all, 0 when not known
type Part ¶
type Part struct {
Name, Value string
// File to upload under the name, with its type, guessed from the extension when empty
File, Type string
}
One field or file of a multipart form
type Persona ¶
type Persona struct {
ID, Name string
Languages []string
Gender string
Styles []string
Rate int
About string
Preview string
}
One voice of a catalog: the id a call or the setting names it by, the name a person knows it by, the languages it speaks as BCP 47 codes, its gender, the styles it speaks in, the samples a second of its audio, what it is, and the address of a sample of it
type Pick ¶
type Pick struct {
Value, Title, About string
}
One value a setting of a service may be picked as, with the name a person knows it by and what it is, both empty for a value that says it all
type Picker ¶
type Picker struct {
// What the tool's description says of picking, in place of the line saying the person picks
Sentence string
// Description of the voice_id argument
About string
// Schema of the find_voices argument
Search map[string]any
// Refusal of a voice id the service would not take
Valid func(id string) error
// One page of voices for a find_voices argument, as the model reads it; an error the model is told
Find func(ctx context.Context, job *Job, query map[string]any) (map[string]any, error)
}
Voices the model may pick from, per call
type Pieces ¶
type Pieces struct {
// contains filtered or unexported fields
}
Speech a voice hands over in numbered pieces as it makes them, played in their order whatever order they come in. The voice waits while the pieces held come to the limit of bytes, so a fast voice never fills memory; a piece played or held already is dropped, as is every piece once the pieces were stopped, such as when the person cut the speech; a voice that sends nothing for the stall ends the speech with what was said
func NewPieces ¶
Numbered pieces of PCM at the rate, holding at most limit bytes before the voice waits, the reader waiting at most first for the first piece and stall for each piece after it; a limit or a wait of zero takes the host's own
func (*Pieces) Done ¶
func (p *Pieces) Done() <-chan struct{}
Closed once the pieces are over: every one played, or stopped
func (*Pieces) End ¶
Says the voice made count pieces in all, and why it failed when it did: those before the count are still played, then the failure is the reader's
func (*Pieces) PCM ¶
The pieces as PCM at their rate, played in their order as they come; the speech ends at the last piece, at the failure of the voice, at a stall with what was said, or once the reader stops, which stops the pieces as letting go of the PCM does
func (*Pieces) Put ¶
Hands over the piece of the number, from 0, waiting while the pieces held come to the limit unless it is the one played next, which is always taken so the speech goes on. A piece played or held already is dropped and the voice goes on; false once the pieces are over, a piece past the count the voice ended with, or the context ended, the piece dropped
type Placeholder ¶
A placeholder a command must name: one of the names will do
type Profiles ¶
Speech as profiles are made: a new profile takes the recognizer, voice and voice input settings of the profile it was made from that it has none of its own of, unless it takes nothing from it
type Programs ¶
type Programs struct {
// Section they may also sit directly under, and the table that holds them
Section, Table string
// Placeholders a command must name, each a set of which one will do, with what goes there
Needs []Placeholder
// Setting that chooses the service in use
Choice string
// contains filtered or unexported fields
}
Programs of yours of one kind: where their entries are kept, the placeholders a command must name and the services whose names they can't take
func (Programs) Add ¶
Adds a program of yours with its command, after the checks of its name and command
func (Programs) Change ¶
Changes one field of a program of yours, null putting its default back, that field alone written so the rest of the program stays as written; refused when the program could then not run as it reads
func (Programs) Command ¶
Why a command can't run as a program of this kind, nil when it can: empty, or naming none of the names of a placeholder it needs
func (Programs) Guard ¶
Guard of the table of programs: a write that would keep a program that can't run is refused, whichever way it comes, and a program the settings rename is renamed as Rename renames it, the choice of it following
func (Programs) Key ¶
Key of a program of yours as the settings keep it, its name as the settings file spells it: under the table, or directly under the section when it sits there; empty for a name no program has
func (Programs) Name ¶
Why a name can't be a new program's, nil when it can: not a name a key holds, or the name of a service there is already. Old is the name of the program given the new one, empty for a program added, which keeps its own name in any case
type Recognition ¶
type Recognition struct {
// Recognizer in use: the one stt.provider names, its fallback while that one can't and the fallback can, else the first that is ready
// of the local engines and then the cloud services; None when none is named and none is ready
Name string
// stt.provider as written, empty for Automatic
Chosen string
// The recognizer of Name, its zero value for a name no recognizer has
Recognizer Recognizer
// How the recognizer of Name stands
Standing Standing
// What keeps speech from being turned into text, nil while nothing does
Hindrance *Hindrance
}
The recognizer the profile turns speech into text with, and whether it can now
func (Recognition) Label ¶
func (r Recognition) Label() string
Short name of the recognizer in use for the logs, empty for none
type Recognizer ¶
type Recognizer struct {
// As stt.provider names it
Name string
Title string
About string
// Short name the voice requirements show it by, such as Groq or command: name; the title when empty
Label string
// What the log names it by when no local engine is installed and it transcribes in their place, such as Groq Whisper API
Detected string
// Warning logged when stt.provider names it and neither it nor its fallback can transcribe; empty logs its reason after the name
Warning string
// Info logged when its fallback transcribes in its place, nothing logged when empty
Instead string
// Runs on this machine: no upload cap applies and Apple's CAF is read as it is
Local bool
// A program of yours, which the settings hold
Program bool
// A cloud service, whose uploads have their silence trimmed
Cloud bool
// Place among the cloud services stt.provider falls back to when no local engine is installed, lower first; 0 for none
Rank int
// Why it can't transcribe with the profile's settings now, empty when it can, never installing anything
Missing func(ctx context.Context, job *Job) string
// Service tried in its place when it is chosen but missing, such as the other local engine
Fallback string
// Model it transcribes with, the call's own first, then its setting
Model func(job *Job, model string) string
// Language its own setting gives, empty to leave it to stt.language
Language func(job *Job) string
// Hint text its own setting gives, empty to leave it to stt.prompt
Prompt func(job *Job) string
// Byte and duration caps of one upload with the model, none for a local engine
Limit func(model string) Limit
// Of the whisper family, which reads only the last 224 tokens of a prompt, so a longer one is cut to them
Whisper bool
Transcribe func(ctx context.Context, job *Job, path string, hints Hints) Transcript
// Live session of the speech as it is spoken, nil for a recognizer that only transcribes whole files
Live func(ctx context.Context, job *Job, hints Hints, partial func(string)) (Live, error)
// What a person sets up to use it
Setup Setup
// Settings of it a person picks from a list on its page in Voice, such as its model
Choices []Choices
}
A service that turns speech into text, what a speech plugin registers as a recognizer
func (Recognizer) CloudFailure ¶
func (r Recognizer) CloudFailure(err error, path, label, detail string) Transcript
Transcript of a failed call to a service's own API: the file's permission, the reply's own message, else the label and detail
func (Recognizer) Failure ¶
func (r Recognizer) Failure(message string) Transcript
Transcript of a failure of a recognizer, named
func (Recognizer) Heard ¶
func (r Recognizer) Heard(text string) Transcript
Transcript of a success of a recognizer
func (Recognizer) OpenAIFailure ¶
func (r Recognizer) OpenAIFailure(err error, path, label string) Transcript
Transcript of a failed call to an OpenAI style transcription API: the file's permission, the reply's own message, the connection, the status, else the error itself
func (Recognizer) Replied ¶
func (r Recognizer) Replied(response *http.Response, err error, path, label string, detail func(map[string]any) string, text func(map[string]any) (string, error)) (Transcript, map[string]any)
Transcript of a service's reply to an upload: an error status with the detail the reply gives else its start, an empty transcript as nothing said, else the text found in the reply
type Registrant ¶
type Registrant interface {
Voices(cfg *config.Config) []Voice
Recognizers(cfg *config.Config) []Recognizer
Engines(cfg *config.Config) []Engine
}
What a speech plugin adds for the profile of the settings: voices, recognizers and wake engines, such as those of programs its settings name and of the extensions it installed
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) Engines ¶
Wake engines of the profile, a name or alias an earlier engine took never given to a later one, so an extension never shadows a built in engine
func (*Registry) Host ¶
Host the registry is nested in, through which surfaces speak, transcribe and listen
func (*Registry) Recognizer ¶
func (*Registry) Recognizers ¶
func (r *Registry) Recognizers(cfg *config.Config) []Recognizer
Recognizers of the profile, a name an earlier recognizer took never given to a later one, as with the voices
func (*Registry) Register ¶
func (r *Registry) Register(registrant Registrant)
func (*Registry) Voice ¶
Voice of the name for the profile, the first registered of a name winning so a program of yours never shadows a built in one
func (*Registry) Voices ¶
Voices of the profile, a name an earlier voice took never given to a later one, so an extension or a program of yours never shadows a built in voice; the voices of a voice's catalog offered in its pickers
func (*Registry) WakeEngine ¶
Engine of the profile a wake_word.provider setting resolves to, auto taking the open vocabulary engine this machine has a build of unless a model file is set, else the first by rank this machine has a build of, else the first by rank; false for a name no engine has. The engines are in the fixed order their plugins register them, so the choice is the same on every run
type ReplyError ¶
type ReplyError struct{ Message string }
Reply of a structured transcription without text, its message as the service gave it
func (*ReplyError) Error ¶
func (e *ReplyError) Error() string
type Request ¶
type Request struct {
Text string
// File to write, whose extension names the format: .mp3 unless asked otherwise, .ogg for a voice bubble, .wav for PCM
Path string
// Speed the call asked for, 0.25 to 4, 0 when it asked none
Speed float64
// How to speak, which the services that take voice design follow
Instructions string
// Voice the call picked, such as an ElevenLabs voice id, empty for the configured one
Voice string
}
One piece of speech a voice is asked to write
type Resampler ¶
type Resampler struct {
// contains filtered or unexported fields
}
Resamples s16le mono PCM between rates across chunk boundaries, averaging whole ratios and interpolating others
func NewResampler ¶
type Resident ¶
type Resident[T Model] struct { // contains filtered or unexported fields }
Models a local voice keeps loaded by what they were loaded with, the least recently used closed once more than three are held, each closed after the request it serves
type Search ¶
What a search of a catalog asks: words of a voice's name or description, a language, a gender, the cursor of the page asked for, empty for the first, and the most voices the page holds
type Services ¶
type Services struct {
Speakers []Voice
Recognizing []Recognizer
Waking []Engine
}
Services fixed once they are registered, whatever the profile
func (Services) Recognizers ¶
func (s Services) Recognizers(*config.Config) []Recognizer
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A live transcription feeding 16 kHz PCM to a service on one worker, its partial text handed out as it changes
func Socketed ¶
func Socketed(ctx context.Context, env httpx.Env, provider, url string, headers http.Header, rate int, wire Wire, partial func(string)) *Session
Live session of a service at a websocket address, reached through the proxy and authorities of the environment, the profile's, fed audio at the rate given; its worker starts at once
func (*Session) Cancel ¶
func (s *Session) Cancel()
Stops the worker, the session finishing as cancelled
func (*Session) Finish ¶
func (s *Session) Finish(timeout float64) Transcript
Ends the audio and waits for the final transcript, a failure when the service keeps it longer than the timeout
func (*Session) Heard ¶
func (s *Session) Heard(text string) *Transcript
Transcript a session finished with as a success
func (*Session) Refused ¶
func (s *Session) Refused(message string) *Transcript
Failure the service reported
type Setup ¶
type Setup struct {
// Variables of the profile's environment that hold its key, the first taking a key pasted in setup
Keys []string
// Provider kind whose sign in serves it in place of a key, connected in Providers
SignIn string
// Python set it runs in, installed on request
Extra string
// Programs of this machine it needs besides, such as espeak-ng
Programs []string
// Where to get a key
Link string
// What it costs and whether it is the one to start with, as the setup lists it: recommended · free, paid, free tier, free
Badge string
// What it needs to run when none of the rest says, after Needs, such as a whisper program; empty for a service that runs once the rest is
// there
Needs string
}
What a person sets up to use a service
type Sink ¶
Where a piece of speech the app plays comes from: the start of each clip, its format and the rate of PCM, then its bytes
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
Websocket of a live session, read on a goroutine of its own so a wait for an event can time out
type Speaking ¶
type Speaking struct {
// As tts.provider names it, Edge when it names none
Name string
// The voice of Name, its zero value for a name no voice has
Voice Voice
Standing Standing
// What keeps replies from being read aloud, nil while nothing does
Hindrance *Hindrance
}
The voice the profile reads replies aloud with, and whether it can now
type Speech ¶
type Speech struct {
Registry
// contains filtered or unexported fields
}
Speech of every profile: the services the plugins registered, and what they run on
func (*Speech) Acquire ¶
Loads the voice the profile speaks with ahead of use, the leases holding it until the last one is dropped
func (*Speech) Assets ¶
Folder of the fetched speech assets, beside which a plugin keeps what it makes of them, such as converted voices
func (*Speech) Dir ¶
Folder of the settings every profile shares, which this machine's speech caches live under
func (*Speech) Drop ¶
Drops a lease, the last one out starting the keep warm window before resident voices unload
func (*Speech) File ¶
Path of the verified asset, downloaded on first use through the proxy and authorities of the environment, that of the profile asking, none meaning no proxy and the system's authorities as the package manager's downloads take it
func (*Speech) Job ¶
Job of a profile outside a session: its own helper models, no surface of a chat app, the paths it touches guarded as the tools guard them
func (*Speech) Local ¶
Job of the profile this process runs in, for what a client does on its own machine such as running a player
func (*Speech) Packages ¶
Package host of this machine, which installs and finds the programs, libraries and Python sets speech runs on
func (*Speech) Reading ¶
Job of a profile for one reading of how its voices and recognizers stand, such as a page of Voice: each program, Python set, provider, credential of a kind of provider and standing of a service its checks ask for looked up once, the programs on its search path and the Python sets those a reading of a moment before found, and the credentials glanced at, nothing renewed or probed while the page waits
func (*Speech) RecognitionPrograms ¶
Programs of yours that turn a recording into text
func (*Speech) Register ¶
func (s *Speech) Register(registrant Registrant)
Adds a registrant; a registry nested in the host reaches it through Host
func (*Speech) SpeechPrograms ¶
Programs of yours that read text aloud
type SpeechRequest ¶
type SpeechRequest struct {
Model, Voice, Text string
// File written, whose extension names the format asked for
Path string
// 1 for none sent
Speed float64
Instructions string
// Fields of the body beside OpenAI's own, such as lang_code
Extra map[string]any
}
One OpenAI style speech call
type Standing ¶
type Standing struct {
State string
// Nil while nothing keeps it from running
Hindrance *Hindrance
// What the service says it lacks in its own words, empty when it lacks nothing
Missing string
}
How a voice or recognizer stands for a profile: the state its row shows and what keeps it from running
type StatusError ¶
A failed reply worded as HTTP libraries word it, with what the service said
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type Stream ¶
type Stream struct {
// Place among the voices tried when tts.streaming.provider is auto, lower first
Rank int
// Name the log gives the stream, such as OpenAI streaming TTS; the title's when empty
Label string
// Whether it can stream with the profile's settings now
Ready func(job *Job) bool
// Opens the sentence's speech: 16 bit little endian mono PCM at the rate answered, which the reply's own headers may change
Open func(ctx context.Context, job *Job, text string) (*PCM, error)
}
PCM a voice makes while it speaks one sentence
type TimeoutError ¶
A program of yours that went quiet past its timeout
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
The seconds written as a fraction, a whole number keeping its .0
type Transcript ¶
type Transcript struct {
Success bool `json:"success"`
Text string `json:"transcript"`
Error string `json:"error,omitempty"`
// Recognizer that answered
Provider string `json:"provider,omitempty"`
// Nothing was said
NoSpeech bool `json:"no_speech,omitempty"`
// What was heard was a known hallucination on silence, so it reads as nothing
Filtered bool `json:"filtered,omitempty"`
// Pieces an upload too large for one request was cut into
Segments int `json:"segments,omitempty"`
// Why nothing claimed the configured service
Kind string `json:"error_type,omitempty"`
}
What a transcription came back with
func Failing ¶
func Failing(err error, path, label string) Transcript
Why a transcription failed, the permission of the file named on its own
type Voice ¶
type Voice struct {
// As tts.provider names it
Name string
Title string
About string
// Name the log says it speaks with, such as OpenAI TTS; the title when empty
Label string
// Runs on this machine
Local bool
// A program of yours, which the settings hold
Program bool
// Whether it can speak with the profile's settings now, its key or engine there, never installing anything
Ready func(job *Job) bool
// Most characters one request takes, which longer text is split under; tts.<name>.max_text_length wins over it
Limit func(job *Job) int
// Writes the speech of the request's text to its path in the format the path's extension names where the service can, answering the
// path it wrote, which may differ
Synthesize func(ctx context.Context, job *Job, request Request) (string, error)
// Speech as PCM while it is made, nil for a voice that writes whole files only
Stream *Stream
// How it gives the Ogg Opus a chat app shows as a voice bubble
Opus Opus
// Extension of the files it writes whatever it is asked, such as a program of yours that writes wav; empty for one that follows the path
Format string
// Readies and frees what it keeps loaded, nil for a voice that keeps nothing
Warm, Release func(ctx context.Context, job *Job) error
// Keeps a model loaded between requests, unloaded once no lease holds speech warm
Resident bool
// Lets the model pick a voice per call and search for one, nil for a voice whose voice the person sets
Picker *Picker
// Voices it speaks with as one catalog, which the host offers as the list of the catalog's setting and, where the model may pick, as
// its Picker; nil for a voice that lists none or gives both itself
Catalog *Catalog
// What a person sets up to use it
Setup Setup
// Settings of it a person picks from a list on its page in Voice, such as its voice or model
Choices []Choices
}
A service that speaks text, what a speech plugin registers as a voice
type Wake ¶
type Wake struct {
Speech *Speech
Phrase string
// 0 to 1, higher catching more
Sensitivity float64
// Over threshold frames in a row that fire, 1 to 10
Frames int
// The phrases other wake enabled profiles chose are heard too
Routing bool
// Profile of the settings, and the phrase of every wake enabled profile
Profile string
Profiles []Phrase
// Engine settings by key, such as its model file
Settings map[string]string
// PORCUPINE_ACCESS_KEY of the profile's environment
AccessKey string
}
Wake settings of a profile as the listener arms with them, and the speech of the machine it listens on
func (*Wake) Getenv ¶
Variable of the environment of the profile of the settings, the one in use for none, empty when it has none or the profile can't be read: what the downloads of the listener reach the network through
type Wire ¶
type Wire interface {
Open(socket *Socket) error
Ready() bool
Send(socket *Socket, chunk []byte) error
// Ends the audio; a transcript it answers finishes the session at once, such as an empty one when no audio was sent
End(socket *Socket) (*Transcript, error)
// Final transcript the event carries, nil while the session goes on
Event(session *Session, event map[string]any) (*Transcript, error)
}
One wire of a live service over a websocket: what it sends first, whether it takes audio yet, how it sends audio and ends it, and the transcript an event finishes with
type Words ¶
What a recognizer heard of the speech: interim words stand until others replace them, final ones are kept
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Page of Voice in the settings menu: voice input and spoken replies, the pages of speech to text, text to speech and the wake word with their services and listeners, each set up there, and the options of each
|
Page of Voice in the settings menu: voice input and spoken replies, the pages of speech to text, text to speech and the wake word with their services and listeners, each set up there, and the options of each |
|
The voice command: the microphones of the computer the server runs on, by the names the Microphone setting takes, so a person who sets it from the command line sees what to set it to
|
The voice command: the microphones of the computer the server runs on, by the names the Microphone setting takes, so a person who sets it from the command line sees what to set it to |
|
Native libraries speech runs on, loaded at run time without cgo: PortAudio, the speech engine and the wake word engines
|
Native libraries speech runs on, loaded at run time without cgo: PortAudio, the speech engine and the wake word engines |
|
What speech needs on this machine: ffmpeg, which converts, trims, splits and joins audio, BtbN's builds on Windows and Linux, martin-riedl's on macOS and Termux's own build with its closure on Android; and pilk, which reads the SILK voice notes of QQ and WeChat
|
What speech needs on this machine: ffmpeg, which converts, trims, splits and joins audio, BtbN's builds on Windows and Linux, martin-riedl's on macOS and Termux's own build with its closure on Android; and pilk, which reads the SILK voice notes of QQ and WeChat |
|
PortAudio, loaded at run time without cgo: the microphones and speakers of this machine, streams of 16 bit samples, one playback of a buffer at a time
|
PortAudio, loaded at run time without cgo: the microphones and speakers of this machine, streams of 16 bit samples, one playback of a buffer at a time |
|
Connect service of speech, through which voice input and the pages of Voice reach the voices and recognizers of the server's profiles
|
Connect service of speech, through which voice input and the pages of Voice reach the voices and recognizers of the server's profiles |
|
The sherpa-onnx speech engine, loaded at run time from its pinned release: offline voices such as Piper's, and keyword spotting
|
The sherpa-onnx speech engine, loaded at run time from its pinned release: offline voices such as Piper's, and keyword spotting |
|
Voice input on the machine the app runs on: recordings from its microphone turned into text by the server, replies the server speaks played on its speakers, talking over a reply to cut it off, and the wake word
|
Voice input on the machine the app runs on: recordings from its microphone turned into text by the server, replies the server speaks played on its speakers, talking over a reply to cut it off, and the wake word |