Documentation ¶
Overview ¶
This package defines interfaces for the live API
Index ¶
Constants ¶
const ( // message types TypeOpenResponse string = "Open" TypeMessageResponse string = "Results" TypeMetadataResponse string = "Metadata" TypeUtteranceEndResponse string = "UtteranceEnd" TypeSpeechStartedResponse string = "SpeechStarted" TypeCloseResponse string = "Close" // Error type TypeErrorResponse string = "Error" )
These are the message types that can be received from the live API
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alternative ¶
type Alternative struct { Confidence float64 `json:"confidence,omitempty"` Transcript string `json:"transcript,omitempty"` Words []Word `json:"words,omitempty"` }
Alternative is a single alternative in a transcript
type Channel ¶
type Channel struct {
Alternatives []Alternative `json:"alternatives,omitempty"`
}
Channel is a single channel in a transcript
type CloseResponse ¶
type CloseResponse struct {
Type string `json:"type,omitempty"`
}
CloseResponse is the response from the connection closing
type ErrorResponse ¶
type ErrorResponse struct { Description string `json:"description"` Message string `json:"message"` Type string `json:"type"` Variant string `json:"variant"` }
ErrorResponse is the response from a live transcription
type LiveMessageCallback ¶
type LiveMessageCallback interface { Open(or *OpenResponse) error Message(mr *MessageResponse) error Metadata(md *MetadataResponse) error SpeechStarted(ssr *SpeechStartedResponse) error UtteranceEnd(ur *UtteranceEndResponse) error Close(cr *CloseResponse) error Error(er *ErrorResponse) error UnhandledEvent(byData []byte) error }
LiveMessageCallback is a callback used to receive notifcations for platforms messages
type LiveTranscriptionOptions ¶
type LiveTranscriptionOptions interfaces.LiveTranscriptionOptions
********************************* Request/Input structs *********************************
type MessageResponse ¶
type MessageResponse struct { Channel Channel `json:"channel,omitempty"` ChannelIndex []int `json:"channel_index,omitempty"` Duration float64 `json:"duration,omitempty"` IsFinal bool `json:"is_final,omitempty"` Metadata Metadata `json:"metadata,omitempty"` SpeechFinal bool `json:"speech_final,omitempty"` Start float64 `json:"start,omitempty"` Type string `json:"type,omitempty"` }
MessageResponse is the response from a live transcription
type Metadata ¶
type Metadata struct { Extra map[string]string `json:"extra,omitempty"` ModelInfo ModelInfo `json:"model_info,omitempty"` ModelUUID string `json:"model_uuid,omitempty"` RequestID string `json:"request_id,omitempty"` }
Metadata is the metadata for a transcript
type MetadataResponse ¶
type MetadataResponse struct { Channels int `json:"channels,omitempty"` Created string `json:"created,omitempty"` Duration float64 `json:"duration,omitempty"` ModelInfo map[string]ModelInfo `json:"model_info,omitempty"` Models []string `json:"models,omitempty"` RequestID string `json:"request_id,omitempty"` Sha256 string `json:"sha256,omitempty"` TransactionKey string `json:"transaction_key,omitempty"` Type string `json:"type,omitempty"` Extra map[string]string `json:"extra,omitempty"` }
MetadataResponse is the response from a live transcription
type ModelInfo ¶
type ModelInfo struct { Arch string `json:"arch,omitempty"` Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` }
ModelInfo is the model information for a transcript
type OpenResponse ¶
type OpenResponse struct {
Type string `json:"type,omitempty"`
}
OpenResponse is the response from the connection starting
type SpeechStartedResponse ¶
type UtteranceEndResponse ¶
type UtteranceEndResponse struct { Type string `json:"type,omitempty"` Channel []int `json:"channel,omitempty"` LastWordEnd float64 `json:"last_word_end,omitempty"` }
UtteranceEndResponse is the response from a live transcription
type Word ¶
type Word struct { Confidence float64 `json:"confidence,omitempty"` End float64 `json:"end,omitempty"` PunctuatedWord string `json:"punctuated_word,omitempty"` Start float64 `json:"start,omitempty"` Word string `json:"word,omitempty"` Speaker *int `json:"speaker,omitempty"` }
********************************* shared/common structs ********************************* Word is a single word in a transcript