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/omni-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 GetCallSystemProvider(name string, opts ...ProviderOption) (callsystem.CallSystem, error)
- func GetSTTProvider(name string, opts ...ProviderOption) (stt.Provider, error)
- func GetTTSProvider(name string, opts ...ProviderOption) (tts.Provider, error)
- func HasCallSystemProvider(name string) bool
- func HasSTTProvider(name string) bool
- func HasTTSProvider(name string) bool
- func ListCallSystemProviders() []string
- func ListSTTProviders() []string
- func ListTTSProviders() []string
- func RegisterCallSystemProvider(name string, factory CallSystemProviderFactory)
- 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 CallSystemClient
- type CallSystemConfig
- type CallSystemProviderFactory
- type ProviderConfig
- type ProviderOption
- func WithAPIKey(apiKey string) ProviderOption
- func WithAccountSID(sid string) ProviderOption
- func WithAuthToken(token string) ProviderOption
- func WithBaseURL(baseURL string) ProviderOption
- func WithExtension(key string, value any) ProviderOption
- func WithPhoneNumber(number string) ProviderOption
- func WithRegion(region string) ProviderOption
- func WithWebhookURL(url string) 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 Transcript
- type TranscriptMetadata
- type TranscriptOptions
- type TranscriptSegment
- type TranscriptWord
- 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 TranscriptFormatVersion = stt.TranscriptFormatVersion
TranscriptFormatVersion is the current version of the OmniVoice transcript format.
const TranscriptSchemaURL = stt.TranscriptSchemaURL
TranscriptSchemaURL is the JSON Schema URL for the transcript format.
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 NewCallSystemClient = callsystem.NewClient
NewCallSystemClient creates a new CallSystem client with the given providers. The first provider becomes the primary by default.
var NewSTTClient = stt.NewClient
Re-export STT functions
var NewTTSClient = tts.NewClient
Re-export TTS functions
Functions ¶
func GetCallSystemProvider ¶ added in v0.7.0
func GetCallSystemProvider(name string, opts ...ProviderOption) (callsystem.CallSystem, error)
GetCallSystemProvider creates a CallSystem provider by name with the given options.
Example:
cs, err := omnivoice.GetCallSystemProvider("twilio",
omnivoice.WithAccountSID(accountSID),
omnivoice.WithAuthToken(authToken),
omnivoice.WithPhoneNumber(phoneNumber),
omnivoice.WithWebhookURL(webhookURL),
)
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 HasCallSystemProvider ¶ added in v0.7.0
HasCallSystemProvider checks if a CallSystem provider is registered.
func HasSTTProvider ¶
HasSTTProvider checks if an STT provider is registered.
func HasTTSProvider ¶
HasTTSProvider checks if a TTS provider is registered.
func ListCallSystemProviders ¶ added in v0.7.0
func ListCallSystemProviders() []string
ListCallSystemProviders returns the names of all registered CallSystem providers.
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 RegisterCallSystemProvider ¶ added in v0.7.0
func RegisterCallSystemProvider(name string, factory CallSystemProviderFactory)
RegisterCallSystemProvider registers a CallSystem provider factory by name. This is typically called from provider init() functions.
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 CallSystemClient ¶ added in v0.7.0
type CallSystemClient = callsystem.Client
CallSystemClient manages multiple CallSystem providers with fallback support.
type CallSystemConfig ¶ added in v0.6.0
type CallSystemConfig = callsystem.CallSystemConfig
CallSystemConfig configures a call system integration.
type CallSystemProviderFactory ¶ added in v0.7.0
type CallSystemProviderFactory func(config ProviderConfig) (callsystem.CallSystem, error)
CallSystemProviderFactory creates a CallSystem provider with the given configuration.
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 WithAccountSID ¶ added in v0.7.0
func WithAccountSID(sid string) ProviderOption
WithAccountSID sets the account SID (Twilio).
func WithAuthToken ¶ added in v0.7.0
func WithAuthToken(token string) ProviderOption
WithAuthToken sets the auth token (Twilio).
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.
func WithPhoneNumber ¶ added in v0.7.0
func WithPhoneNumber(number string) ProviderOption
WithPhoneNumber sets the default outbound phone number.
func WithRegion ¶ added in v0.7.0
func WithRegion(region string) ProviderOption
WithRegion sets the service region.
func WithWebhookURL ¶ added in v0.7.0
func WithWebhookURL(url string) ProviderOption
WithWebhookURL sets the webhook URL for incoming calls.
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 Transcript ¶ added in v0.8.0
type Transcript = stt.Transcript
Type aliases for backwards compatibility.
func LoadTranscript ¶ added in v0.8.0
func LoadTranscript(filePath string) (*Transcript, error)
LoadTranscript reads a transcript from a JSON file.
func NewTranscript ¶ added in v0.8.0
func NewTranscript(result *TranscriptionResult, provider, model, audioFile string, config *TranscriptionConfig) *Transcript
NewTranscript creates a Transcript from a TranscriptionResult. This is a convenience wrapper around stt.NewTranscript.
type TranscriptMetadata ¶ added in v0.8.0
type TranscriptMetadata = stt.TranscriptMetadata
Type aliases for backwards compatibility.
type TranscriptOptions ¶ added in v0.8.0
type TranscriptOptions = stt.TranscriptOptions
Type aliases for backwards compatibility.
type TranscriptSegment ¶ added in v0.8.0
type TranscriptSegment = stt.TranscriptSegment
Type aliases for backwards compatibility.
type TranscriptWord ¶ added in v0.8.0
type TranscriptWord = stt.TranscriptWord
Type aliases for backwards compatibility.
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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
omnivoice
command
Package main provides the entry point for the omnivoice CLI.
|
Package main provides the entry point for the omnivoice CLI. |
|
internal
|
|
|
cli
Package cli provides the command-line interface for omnivoice.
|
Package cli provides the command-line interface for omnivoice. |
|
providers
|
|
|
all
Package all imports and registers all omnivoice providers.
|
Package all imports and registers all omnivoice providers. |
|
Package schema re-exports JSON Schema definitions from omnivoice-core.
|
Package schema re-exports JSON Schema definitions from omnivoice-core. |