interfaces

package
v1.3.1-0...-b434ee1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

This package defines interfaces for the live API

Index

Constants

View Source
const (
	// message types
	TypeOpenResponse          string = "Open"
	TypeMessageResponse       string = "Results"
	TypeMetadataResponse      string = "Metadata"
	TypeUtteranceEndResponse  string = "UtteranceEnd"
	TypeSpeechStartedResponse string = "SpeechStarted"
	TypeFinalizeResponse      string = "Finalize"
	TypeCloseStreamResponse   string = "CloseStream"
	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 added in v1.1.6

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 added in v1.2.0

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"`
	FromFinalize bool     `json:"from_finalize,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 added in v1.1.6

type OpenResponse struct {
	Type string `json:"type,omitempty"`
}

OpenResponse is the response from the connection starting

type SpeechStartedResponse added in v1.1.1

type SpeechStartedResponse struct {
	Type      string  `json:"type,omitempty"`
	Channel   []int   `json:"channel,omitempty"`
	Timestamp float64 `json:"timestamp,omitempty"`
}

type UtteranceEndResponse added in v1.0.2

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

Jump to

Keyboard shortcuts

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