Documentation
¶
Overview ¶
Package omnivoice provides a unified interface for speech-to-text and text-to-speech. This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omnivoice-core instead.
Package omnivoice provides a unified interface for speech-to-text and text-to-speech.
This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omnivoice-core instead.
Quick Start ¶
Import the package with all providers:
import (
"github.com/plexusone/omnivoice"
_ "github.com/plexusone/omnivoice/providers/all"
)
Or import specific providers:
import (
"github.com/plexusone/omnivoice"
openai "github.com/plexusone/omnivoice-openai/omnivoice"
)
Creating Providers ¶
// OpenAI provider sttProvider := openai.NewSTTProvider(apiKey) ttsProvider := openai.NewTTSProvider(apiKey) // Create multi-provider client sttClient := omnivoice.NewSTTClient(sttProvider) ttsClient := omnivoice.NewTTSClient(ttsProvider)
Package omnivoice provides a unified interface for speech-to-text and text-to-speech. This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omnivoice-core instead.
Package omnivoice provides a unified interface for speech-to-text and text-to-speech. This is the batteries-included package that imports all providers. For a minimal dependency footprint, use github.com/plexusone/omnivoice-core instead.
Index ¶
- Constants
- Variables
- func GetSTTProvider(name string, opts ...ProviderOption) (stt.Provider, error)
- func GetTTSProvider(name string, opts ...ProviderOption) (tts.Provider, error)
- func HasSTTProvider(name string) bool
- func HasTTSProvider(name string) bool
- func ListSTTProviders() []string
- func ListTTSProviders() []string
- func RegisterSTTProvider(name string, factory STTProviderFactory)
- func RegisterTTSProvider(name string, factory TTSProviderFactory)
- type Call
- type CallDirection
- type CallHandler
- type CallOption
- type CallOptions
- type CallStatus
- type CallSystem
- type CallSystemConfig
- type ProviderConfig
- type ProviderOption
- type STTClient
- type STTProvider
- type STTProviderFactory
- type STTStreamingProvider
- type Segment
- type StreamEvent
- type SubtitleFormat
- type SubtitleOptions
- type SynthesisConfig
- type SynthesisResult
- type TTSClient
- type TTSProvider
- type TTSProviderFactory
- type TTSStreamChunk
- type TTSStreamingProvider
- type TranscriptionConfig
- type TranscriptionResult
- type Voice
- type Word
Constants ¶
const ( StatusRinging = callsystem.StatusRinging StatusAnswered = callsystem.StatusAnswered StatusEnded = callsystem.StatusEnded StatusFailed = callsystem.StatusFailed StatusBusy = callsystem.StatusBusy StatusNoAnswer = callsystem.StatusNoAnswer CallInbound = callsystem.Inbound CallOutbound = callsystem.Outbound )
Re-export CallStatus constants
const ( SubtitleFormatSRT = subtitle.FormatSRT SubtitleFormatVTT = subtitle.FormatVTT )
Subtitle format constants.
const Version = "0.6.0"
Version is the current version of the omnivoice package.
Variables ¶
var ( WithFrom = callsystem.WithFrom WithTimeout = callsystem.WithTimeout WithMachineDetection = callsystem.WithMachineDetection WithRecording = callsystem.WithRecording WithWhisper = callsystem.WithWhisper WithAgent = callsystem.WithAgent WithStatusCallback = callsystem.WithStatusCallback )
Re-export CallOption functions
var ( ErrNoAvailableProvider = stt.ErrNoAvailableProvider ErrStreamingNotSupported = stt.ErrStreamingNotSupported ErrInvalidAudio = stt.ErrInvalidAudio ErrInvalidConfig = stt.ErrInvalidConfig ErrAudioTooLong = stt.ErrAudioTooLong ErrAudioTooShort = stt.ErrAudioTooShort ErrRateLimited = stt.ErrRateLimited ErrQuotaExceeded = stt.ErrQuotaExceeded ErrUnsupportedLanguage = stt.ErrUnsupportedLanguage ErrUnsupportedFormat = stt.ErrUnsupportedFormat ErrStreamClosed = stt.ErrStreamClosed )
Re-export STT errors
var ( // DefaultSubtitleOptions returns sensible defaults for subtitle generation. DefaultSubtitleOptions = subtitle.DefaultOptions // GenerateSRT generates SRT subtitles from a transcription result. GenerateSRT = subtitle.GenerateSRT // GenerateVTT generates WebVTT subtitles from a transcription result. GenerateVTT = subtitle.GenerateVTT // SaveSRT generates and saves SRT to a file. SaveSRT = subtitle.SaveSRT // SaveVTT generates and saves WebVTT to a file. SaveVTT = subtitle.SaveVTT )
Re-export subtitle functions.
var ( ErrTTSNoAvailableProvider = tts.ErrNoAvailableProvider ErrVoiceNotFound = tts.ErrVoiceNotFound ErrTTSInvalidConfig = tts.ErrInvalidConfig ErrTTSRateLimited = tts.ErrRateLimited ErrTTSQuotaExceeded = tts.ErrQuotaExceeded ErrTTSStreamClosed = tts.ErrStreamClosed )
Re-export TTS errors
var NewSTTClient = stt.NewClient
Re-export STT functions
var NewTTSClient = tts.NewClient
Re-export TTS functions
Functions ¶
func GetSTTProvider ¶
func GetSTTProvider(name string, opts ...ProviderOption) (stt.Provider, error)
GetSTTProvider creates an STT provider by name with the given options.
Example:
provider, err := omnivoice.GetSTTProvider("deepgram", omnivoice.WithAPIKey(apiKey))
func GetTTSProvider ¶
func GetTTSProvider(name string, opts ...ProviderOption) (tts.Provider, error)
GetTTSProvider creates a TTS provider by name with the given options.
Example:
provider, err := omnivoice.GetTTSProvider("elevenlabs", omnivoice.WithAPIKey(apiKey))
func HasSTTProvider ¶
HasSTTProvider checks if an STT provider is registered.
func HasTTSProvider ¶
HasTTSProvider checks if a TTS provider is registered.
func ListSTTProviders ¶
func ListSTTProviders() []string
ListSTTProviders returns the names of all registered STT providers.
func ListTTSProviders ¶
func ListTTSProviders() []string
ListTTSProviders returns the names of all registered TTS providers.
func RegisterSTTProvider ¶
func RegisterSTTProvider(name string, factory STTProviderFactory)
RegisterSTTProvider registers an STT provider factory by name. This is typically called from provider init() functions.
func RegisterTTSProvider ¶
func RegisterTTSProvider(name string, factory TTSProviderFactory)
RegisterTTSProvider registers a TTS provider factory by name. This is typically called from provider init() functions.
Types ¶
type CallDirection ¶ added in v0.6.0
type CallDirection = callsystem.CallDirection
CallDirection indicates inbound or outbound call.
type CallHandler ¶ added in v0.6.0
type CallHandler = callsystem.CallHandler
CallHandler is called when a new call arrives.
type CallOption ¶ added in v0.6.0
type CallOption = callsystem.CallOption
CallOption configures an outbound call.
type CallOptions ¶ added in v0.6.0
type CallOptions = callsystem.CallOptions
CallOptions holds parsed options for MakeCall.
type CallStatus ¶ added in v0.6.0
type CallStatus = callsystem.CallStatus
CallStatus represents the call state.
type CallSystem ¶ added in v0.6.0
type CallSystem = callsystem.CallSystem
CallSystem defines the interface for telephony/meeting integrations.
type CallSystemConfig ¶ added in v0.6.0
type CallSystemConfig = callsystem.CallSystemConfig
CallSystemConfig configures a call system integration.
type ProviderConfig ¶
type ProviderConfig struct {
// APIKey is the authentication key for the provider.
APIKey string //nolint:gosec // G117: This is a config struct, not storing secrets
// BaseURL is an optional custom API endpoint.
BaseURL string
// Extensions holds provider-specific configuration.
Extensions map[string]any
}
ProviderConfig holds common configuration options for creating providers.
type ProviderOption ¶
type ProviderOption func(*ProviderConfig)
ProviderOption configures a ProviderConfig.
func WithAPIKey ¶
func WithAPIKey(apiKey string) ProviderOption
WithAPIKey sets the API key for the provider.
func WithBaseURL ¶
func WithBaseURL(baseURL string) ProviderOption
WithBaseURL sets a custom base URL for the provider.
func WithExtension ¶
func WithExtension(key string, value any) ProviderOption
WithExtension sets a provider-specific configuration value.
type STTProvider ¶
STTProvider defines the interface for STT providers.
type STTProviderFactory ¶
type STTProviderFactory func(config ProviderConfig) (stt.Provider, error)
STTProviderFactory creates an STT provider with the given configuration.
type STTStreamingProvider ¶
type STTStreamingProvider = stt.StreamingProvider
STTStreamingProvider extends Provider with streaming support.
type StreamEvent ¶
type StreamEvent = stt.StreamEvent
StreamEvent represents a streaming transcription event.
type SubtitleFormat ¶
SubtitleFormat represents the output format for subtitles.
type SubtitleOptions ¶
SubtitleOptions configures subtitle generation.
type SynthesisConfig ¶
type SynthesisConfig = tts.SynthesisConfig
SynthesisConfig configures a TTS synthesis request.
type SynthesisResult ¶
type SynthesisResult = tts.SynthesisResult
SynthesisResult contains the result of a TTS synthesis.
type TTSProvider ¶
TTSProvider defines the interface for TTS providers.
type TTSProviderFactory ¶
type TTSProviderFactory func(config ProviderConfig) (tts.Provider, error)
TTSProviderFactory creates a TTS provider with the given configuration.
type TTSStreamChunk ¶
type TTSStreamChunk = tts.StreamChunk
StreamChunk represents a chunk of streaming audio.
type TTSStreamingProvider ¶
type TTSStreamingProvider = tts.StreamingProvider
TTSStreamingProvider extends Provider with input streaming support.
type TranscriptionConfig ¶
type TranscriptionConfig = stt.TranscriptionConfig
TranscriptionConfig configures a STT transcription request.
type TranscriptionResult ¶
type TranscriptionResult = stt.TranscriptionResult
TranscriptionResult contains the result of a STT transcription.