livekit

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HGModel          = "livekit/turn-detector"
	ONNXFilename     = "model_q8.onnx"
	MaxHistoryTokens = 128
	MaxHistoryTurns  = 6

	RemoteInferenceTimeout = 2 * time.Second
)
View Source
const (
	PluginTitle   = "rtp-agent.plugins.livekit"
	PluginVersion = "v0.1.2"
	PluginPackage = "rtp-agent.plugins.livekit"
)
View Source
const (
	InferenceAccessTokenTTL = 10 * time.Minute

	HeaderUserAgent         = "User-Agent"
	HeaderRoomID            = inference.HeaderRoomID
	HeaderJobID             = inference.HeaderJobID
	HeaderInferenceProvider = inference.HeaderInferenceProvider
	HeaderInferencePriority = inference.HeaderInferencePriority
)

Variables

This section is empty.

Functions

func AddContextHeaders

func AddContextHeaders(headers http.Header)

func CreateAccessToken

func CreateAccessToken(apiKey, apiSecret string, ttl time.Duration) (string, error)

func InferenceHeaders

func InferenceHeaders() http.Header

func ModelLanguagesPath

func ModelLanguagesPath(modelType ModelType) (string, error)

func ModelLanguagesPathIn

func ModelLanguagesPathIn(rootDir string, modelType ModelType) string

func ModelONNXPath

func ModelONNXPath(modelType ModelType) (string, error)

func ModelONNXPathIn

func ModelONNXPathIn(rootDir string, modelType ModelType) string

func ModelTokenizerPath

func ModelTokenizerPath(modelType ModelType) (string, error)

func ModelTokenizerPathIn

func ModelTokenizerPathIn(rootDir string, modelType ModelType) string

func RemoteInferenceURL

func RemoteInferenceURL(urlBase string) string

func SetContextHeadersProvider

func SetContextHeadersProvider(provider func() map[string]string) func()

Types

type APIConnectOptions

type APIConnectOptions = llm.APIConnectOptions

type FallbackModel

type FallbackModel struct {
	Model       string         `json:"model"`
	Voice       string         `json:"voice"`
	ExtraKwargs map[string]any `json:"extra,omitempty"`
}

type LiveKitInferenceLLM

type LiveKitInferenceLLM struct {
	// contains filtered or unexported fields
}

func NewLiveKitInferenceLLM

func NewLiveKitInferenceLLM(model string, apiKey, apiSecret string, opts ...LiveKitInferenceLLMOption) (*LiveKitInferenceLLM, error)

func (*LiveKitInferenceLLM) Chat

func (l *LiveKitInferenceLLM) Chat(ctx context.Context, chatCtx *llm.ChatContext, opts ...llm.ChatOption) (llm.LLMStream, error)

func (*LiveKitInferenceLLM) Model

func (l *LiveKitInferenceLLM) Model() string

func (*LiveKitInferenceLLM) Provider

func (l *LiveKitInferenceLLM) Provider() string

func (*LiveKitInferenceLLM) UpdateOptions

func (l *LiveKitInferenceLLM) UpdateOptions(opts ...LiveKitInferenceLLMOption)

type LiveKitInferenceLLMOption

type LiveKitInferenceLLMOption func(*LiveKitInferenceLLM)

func WithLiveKitInferenceLLMClass

func WithLiveKitInferenceLLMClass(inferenceClass string) LiveKitInferenceLLMOption

func WithLiveKitInferenceLLMExtraParams

func WithLiveKitInferenceLLMExtraParams(params map[string]any) LiveKitInferenceLLMOption

func WithLiveKitInferenceLLMModel

func WithLiveKitInferenceLLMModel(model string) LiveKitInferenceLLMOption

func WithLiveKitInferenceLLMProvider

func WithLiveKitInferenceLLMProvider(provider string) LiveKitInferenceLLMOption

type LocalTurnDetectorRunner

type LocalTurnDetectorRunner struct {
	// contains filtered or unexported fields
}

func (*LocalTurnDetectorRunner) RunTurnDetector

func (r *LocalTurnDetectorRunner) RunTurnDetector(ctx context.Context, payload []byte) (float64, error)

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewEnglishModel

func NewEnglishModel(opts ...ModelOption) *Model

func NewLocalEnglishModel

func NewLocalEnglishModel(opts ...ModelOption) (*Model, error)

func NewLocalMultilingualModel

func NewLocalMultilingualModel(opts ...ModelOption) (*Model, error)

func NewMultilingualModel

func NewMultilingualModel(opts ...ModelOption) *Model

func (*Model) InferenceMethod

func (m *Model) InferenceMethod() string

func (*Model) InferencePayload

func (m *Model) InferencePayload(chatCtx *llm.ChatContext) ([]byte, error)

func (*Model) Model

func (m *Model) Model() ModelType

func (*Model) ModelRevision

func (m *Model) ModelRevision() string

func (*Model) PredictEndOfTurn

func (m *Model) PredictEndOfTurn(ctx context.Context, chatCtx *llm.ChatContext) (float64, error)

func (*Model) Provider

func (m *Model) Provider() string

func (*Model) RemoteInferenceURL

func (m *Model) RemoteInferenceURL() string

func (*Model) UnlikelyThreshold

func (m *Model) UnlikelyThreshold(language string) (float64, bool)

type ModelOption

type ModelOption func(*Model)

func WithHTTPClient

func WithHTTPClient(client *http.Client) ModelOption

func WithLanguageThresholds

func WithLanguageThresholds(thresholds map[string]float64) ModelOption

func WithLanguagesPath

func WithLanguagesPath(path string) ModelOption

func WithRemoteInferenceBaseURL

func WithRemoteInferenceBaseURL(urlBase string) ModelOption

func WithTurnDetectorRunner

func WithTurnDetectorRunner(runner TurnDetectorRunner) ModelOption

func WithUnlikelyThreshold

func WithUnlikelyThreshold(threshold float64) ModelOption

type ModelType

type ModelType string
const (
	ModelEnglish      ModelType = "en"
	ModelMultilingual ModelType = "multilingual"
)

type Plugin

type Plugin struct{}

func (Plugin) DownloadFiles

func (Plugin) DownloadFiles() error

type STT

type STT struct {
	// contains filtered or unexported fields
}

func NewSTT

func NewSTT(model string, apiKey, apiSecret string, opts ...STTOption) *STT

func (*STT) Capabilities

func (s *STT) Capabilities() stt.STTCapabilities

func (*STT) Close

func (s *STT) Close() error

func (*STT) InputSampleRate

func (s *STT) InputSampleRate() uint32

func (*STT) Label

func (s *STT) Label() string

func (*STT) Model

func (s *STT) Model() string

func (*STT) Provider

func (s *STT) Provider() string

func (*STT) Recognize

func (s *STT) Recognize(ctx context.Context, frames []*model.AudioFrame, language string) (*stt.SpeechEvent, error)

func (*STT) Stream

func (s *STT) Stream(ctx context.Context, language string) (stt.RecognizeStream, error)

func (*STT) UpdateOptions

func (s *STT) UpdateOptions(opts ...STTOption)

type STTOption

type STTOption func(*STT)

func WithSTTConnectOptions

func WithSTTConnectOptions(options APIConnectOptions) STTOption

func WithSTTEncoding

func WithSTTEncoding(encoding string) STTOption

func WithSTTExtraKwargs

func WithSTTExtraKwargs(extra map[string]any) STTOption

func WithSTTFallbackModels

func WithSTTFallbackModels(models ...FallbackModel) STTOption

func WithSTTLanguage

func WithSTTLanguage(language string) STTOption

func WithSTTModel

func WithSTTModel(model string) STTOption

func WithSTTSampleRate

func WithSTTSampleRate(sampleRate int) STTOption

type TTS

type TTS struct {
	// contains filtered or unexported fields
}

func NewTTS

func NewTTS(model string, apiKey, apiSecret string, opts ...TTSOption) *TTS

func (*TTS) Capabilities

func (t *TTS) Capabilities() tts.TTSCapabilities

func (*TTS) Close

func (t *TTS) Close() error

func (*TTS) Label

func (t *TTS) Label() string

func (*TTS) Model

func (t *TTS) Model() string

func (*TTS) NumChannels

func (t *TTS) NumChannels() int

func (*TTS) Prewarm

func (t *TTS) Prewarm()

func (*TTS) Provider

func (t *TTS) Provider() string

func (*TTS) SampleRate

func (t *TTS) SampleRate() int

func (*TTS) Stream

func (t *TTS) Stream(ctx context.Context) (tts.SynthesizeStream, error)

func (*TTS) Synthesize

func (t *TTS) Synthesize(ctx context.Context, text string) (tts.ChunkedStream, error)

func (*TTS) UpdateOptions

func (t *TTS) UpdateOptions(opts ...TTSOption)

type TTSOption

type TTSOption func(*TTS)

func WithSentenceTokenizer

func WithSentenceTokenizer(tokenizer tokenize.SentenceTokenizer) TTSOption

func WithTTSConnectOptions

func WithTTSConnectOptions(options APIConnectOptions) TTSOption

func WithTTSEncoding

func WithTTSEncoding(encoding string) TTSOption

func WithTTSExtraKwargs

func WithTTSExtraKwargs(extra map[string]any) TTSOption

func WithTTSFallbackModels

func WithTTSFallbackModels(models ...FallbackModel) TTSOption

func WithTTSLanguage

func WithTTSLanguage(language string) TTSOption

func WithTTSModel

func WithTTSModel(model string) TTSOption

func WithTTSSampleRate

func WithTTSSampleRate(sampleRate int) TTSOption

func WithTTSVoice

func WithTTSVoice(voice string) TTSOption

type TurnDetectorInputRunner

type TurnDetectorInputRunner interface {
	RunTurnDetectorInputIDs(ctx context.Context, inputIDs []int64) (float64, error)
}

func NewTurnDetectorONNXInputRunner

func NewTurnDetectorONNXInputRunner(options TurnDetectorONNXOptions) (TurnDetectorInputRunner, error)

type TurnDetectorONNXOptions

type TurnDetectorONNXOptions struct {
	ModelPath          string
	ONNXRuntimeLibPath string
}

type TurnDetectorRunner

type TurnDetectorRunner interface {
	RunTurnDetector(ctx context.Context, payload []byte) (float64, error)
}

type TurnDetectorTokenizer

type TurnDetectorTokenizer interface {
	TokenizeTurnDetectorPayload(ctx context.Context, payload []byte) ([]int64, error)
}

func NewHuggingFaceTurnDetectorTokenizer

func NewHuggingFaceTurnDetectorTokenizer(modelType ModelType, tokenizerPath string) (TurnDetectorTokenizer, error)

Jump to

Keyboard shortcuts

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