Documentation
¶
Index ¶
- Constants
- Variables
- func CheckOpenaiKey(key string) error
- func ConfigSession()
- func CreateASession()
- func DefaultLogger(level Level) *defaultLog
- func DeleteSession()
- func FormatVoices(voices []*Voice) string
- func GetAutoDetectedLanguages() []string
- func GetAutoDetectedLanguagesName() []string
- func Initialize(chatGPTModel, language, voice, stopWord string)
- func ListSessions()
- func SelectSession()
- func SetLevel(level Level)
- func Showkeyword()
- type ChatGPT
- func (c *ChatGPT) DisableHistory()
- func (c *ChatGPT) Prompt(text string) (string, int, error)
- func (c *ChatGPT) PromptStream(text string) (*StreamResult, error)
- func (c *ChatGPT) SetMaxHistory(n int)
- func (c *ChatGPT) SetModel(model string)
- func (c *ChatGPT) SetRole(text string)
- func (c *ChatGPT) String() string
- type ChatGPTs
- func (c ChatGPTs) DelSession(sessionName string)
- func (c ChatGPTs) GetDefaultGPT() (string, *ChatGPT)
- func (c *ChatGPTs) LoadChatGPTs(file string) error
- func (c ChatGPTs) NewDefaultSession(key string, model string) *ChatGPT
- func (c ChatGPTs) NewSessionWithName(sessionName string, key string, model string) *ChatGPT
- func (c ChatGPTs) RenameSession(oldName string, newName string) *ChatGPT
- func (c ChatGPTs) SaveChatGPTs(file string) error
- func (c ChatGPTs) Sessions() []string
- func (c ChatGPTs) SessionsWithout(name string) []string
- func (c ChatGPTs) SetDefaultGPT(sessionName string)
- type Hook
- type HookConfig
- type Hooks
- func (h *Hooks) Add(keyword string, name string) error
- func (h *Hooks) Delete(id string) bool
- func (h *Hooks) Disable(id string)
- func (h *Hooks) Enable(id string)
- func (h *Hooks) Exec(hookName string) error
- func (h *Hooks) Get(id string) *HookConfig
- func (h *Hooks) IsExist(hookName string) bool
- func (h *Hooks) LoadHooks(file string) error
- func (h *Hooks) SaveHooks(file string) error
- type KeywordRecognitionStandalone
- type Level
- type Logger
- type Params
- type SpeechRecognition
- type SpeechRecognitionStandalone
- type SpeechRecognitionStream
- type SpeechSynthesis
- type SpeechSynthesisStandalone
- type SpeechSynthesisStream
- func (s *SpeechSynthesisStream) Close()
- func (s *SpeechSynthesisStream) Error() error
- func (s *SpeechSynthesisStream) GetAllSupportLanguage() map[string]bool
- func (s *SpeechSynthesisStream) GetAllSupportVoicesForLanguage(language string) []*Voice
- func (s *SpeechSynthesisStream) Result() (*WordBoundery, []byte, error)
- func (s *SpeechSynthesisStream) TextToSpeech(text string) error
- type StreamResult
- type StreamSplitter
- type Voice
- type WordBoundery
Constants ¶
View Source
const AUDIO_FORMT = common.Audio16Khz32KBitRateMonoMp3
Variables ¶
View Source
var ( ErrRepeatConfig = errors.New("found a same config") ErrNoSuchHook = errors.New("hook not exists") )
View Source
var ( ErrSpeechRecognitionTimeout = errors.New("speech recognition get result timeout") MaxSpeechRecognitionDelay = time.Duration(30) SegmentationSilenceTimeoutMs = "1500" //1.5s SpeechServiceConnectionInitialSilenceTimeoutMs = "5000" //5s )
View Source
var ( ErrSpeechSynthesisTimeout = errors.New("speech synthesis get result timeout") MaxSpeechSynthesisDelay = time.Duration(10) )
View Source
var AUTO_DETECTED_LANGUAGE = map[string]string{
"English": "en-US",
"French": "fr-FR",
"Chinese": "zh-CN",
"Spanish": "es-ES",
}
because azure stt go speech sdk only support 4 languages in auto detected by languages (not support full languages auto detected)
View Source
var CHATGPTS = newChatGPTs()
View Source
var HOOKS = newHooks()
View Source
var PARAMS = Params{MaxHistory: 4, Language: "en-US", Voice: "en-US-ElizabethNeural"}
Functions ¶
func CheckOpenaiKey ¶
func ConfigSession ¶
func ConfigSession()
func CreateASession ¶
func CreateASession()
func DefaultLogger ¶
func DefaultLogger(level Level) *defaultLog
func DeleteSession ¶
func DeleteSession()
func FormatVoices ¶
func GetAutoDetectedLanguages ¶
func GetAutoDetectedLanguages() []string
func GetAutoDetectedLanguagesName ¶
func GetAutoDetectedLanguagesName() []string
func Initialize ¶
func Initialize(chatGPTModel, language, voice, stopWord string)
func ListSessions ¶
func ListSessions()
func SelectSession ¶
func SelectSession()
func Showkeyword ¶
func Showkeyword()
Types ¶
type ChatGPT ¶
type ChatGPT struct { System *openai.ChatCompletionMessage `json:"system"` History []*openai.ChatCompletionMessage `json:"history"` MaxHistory int `json:"maxHistory"` Model string `json:"model"` Key string `json:"key"` IsDefault bool `json:"default"` // contains filtered or unexported fields }
func NewChatGPT ¶
func (*ChatGPT) DisableHistory ¶
func (c *ChatGPT) DisableHistory()
func (*ChatGPT) PromptStream ¶
func (c *ChatGPT) PromptStream(text string) (*StreamResult, error)
func (*ChatGPT) SetMaxHistory ¶
type ChatGPTs ¶
func (ChatGPTs) DelSession ¶
func (ChatGPTs) GetDefaultGPT ¶
func (*ChatGPTs) LoadChatGPTs ¶
func (ChatGPTs) NewDefaultSession ¶
func (ChatGPTs) NewSessionWithName ¶
func (ChatGPTs) RenameSession ¶
func (ChatGPTs) SaveChatGPTs ¶
func (ChatGPTs) SessionsWithout ¶
func (ChatGPTs) SetDefaultGPT ¶
type HookConfig ¶
type Hooks ¶
type Hooks struct { Configs map[string]*HookConfig `json:"hookConfigs"` // contains filtered or unexported fields }
func (*Hooks) Get ¶
func (h *Hooks) Get(id string) *HookConfig
type KeywordRecognitionStandalone ¶
type KeywordRecognitionStandalone struct { SpeechRecognitionStream KeyWord string // contains filtered or unexported fields }
func NewKeywordRecognitionStandalone ¶
func NewKeywordRecognitionStandalone(key, region string, languages []string, model, keyWord string) (*KeywordRecognitionStandalone, error)
func (*KeywordRecognitionStandalone) Close ¶
func (s *KeywordRecognitionStandalone) Close() error
func (*KeywordRecognitionStandalone) Result ¶
func (s *KeywordRecognitionStandalone) Result() (string, error)
func (*KeywordRecognitionStandalone) SpeechToText ¶
func (s *KeywordRecognitionStandalone) SpeechToText(data []byte) error
func (*KeywordRecognitionStandalone) Start ¶
func (s *KeywordRecognitionStandalone) Start() error
type Params ¶
type Params struct { Initialized bool OpenaiKey string ChatgptModel string MaxHistory int SpeechKey string SpeechRegion string Language string // BCP-47 code Voice string StopWord string Keyword string KeywordModel string KeywordLanguage string }
func (*Params) LoadParams ¶
func (Params) SaveParams ¶
type SpeechRecognition ¶
type SpeechRecognitionStandalone ¶
type SpeechRecognitionStandalone struct {
SpeechRecognitionStream
}
func NewAutoDetectedSpeechRecognitionStandalone ¶
func NewAutoDetectedSpeechRecognitionStandalone(key, region string) (*SpeechRecognitionStandalone, error)
func NewSpeechRecognitionStandalone ¶
func NewSpeechRecognitionStandalone(key, region string, languages []string) (*SpeechRecognitionStandalone, error)
func (*SpeechRecognitionStandalone) SpeechToText ¶
func (s *SpeechRecognitionStandalone) SpeechToText(data []byte) error
type SpeechRecognitionStream ¶
type SpeechRecognitionStream struct {
// contains filtered or unexported fields
}
func NewAutoDetectedSpeechRecognitionStream ¶
func NewAutoDetectedSpeechRecognitionStream(key, region string) (*SpeechRecognitionStream, error)
func NewSpeechRecognitionStream ¶
func NewSpeechRecognitionStream(key, region string, languages []string) (*SpeechRecognitionStream, error)
func (*SpeechRecognitionStream) Close ¶
func (s *SpeechRecognitionStream) Close() error
func (*SpeechRecognitionStream) Result ¶
func (s *SpeechRecognitionStream) Result() (string, error)
func (*SpeechRecognitionStream) SpeechToText ¶
func (s *SpeechRecognitionStream) SpeechToText(data []byte) error
func (*SpeechRecognitionStream) Start ¶
func (s *SpeechRecognitionStream) Start() error
type SpeechSynthesis ¶
type SpeechSynthesisStandalone ¶
type SpeechSynthesisStandalone struct {
SpeechSynthesisStream
}
func NewAutoDetectedSpeechSynthesisStandalone ¶
func NewAutoDetectedSpeechSynthesisStandalone(key, region string) (*SpeechSynthesisStandalone, error)
func NewSpeechSynthesisStandalone ¶
func NewSpeechSynthesisStandalone(key, region string, voice string) (*SpeechSynthesisStandalone, error)
type SpeechSynthesisStream ¶
type SpeechSynthesisStream struct {
// contains filtered or unexported fields
}
func NewAutoDetectedSpeechSynthesisStream ¶
func NewAutoDetectedSpeechSynthesisStream(key, region string) (*SpeechSynthesisStream, error)
func NewSpeechSynthesisStream ¶
func NewSpeechSynthesisStream(key, region string, voice string) (*SpeechSynthesisStream, error)
func (*SpeechSynthesisStream) Close ¶
func (s *SpeechSynthesisStream) Close()
func (*SpeechSynthesisStream) Error ¶
func (s *SpeechSynthesisStream) Error() error
func (*SpeechSynthesisStream) GetAllSupportLanguage ¶
func (s *SpeechSynthesisStream) GetAllSupportLanguage() map[string]bool
func (*SpeechSynthesisStream) GetAllSupportVoicesForLanguage ¶
func (s *SpeechSynthesisStream) GetAllSupportVoicesForLanguage(language string) []*Voice
func (*SpeechSynthesisStream) Result ¶
func (s *SpeechSynthesisStream) Result() (*WordBoundery, []byte, error)
func (*SpeechSynthesisStream) TextToSpeech ¶
func (s *SpeechSynthesisStream) TextToSpeech(text string) error
type StreamResult ¶
type StreamResult struct { Err error // contains filtered or unexported fields }
func (*StreamResult) Next ¶
func (s *StreamResult) Next() string
type StreamSplitter ¶
type StreamSplitter struct {
// contains filtered or unexported fields
}
func NewStreamSplitter ¶
func NewStreamSplitter(stream *StreamResult) StreamSplitter
func (StreamSplitter) Segment ¶
func (ss StreamSplitter) Segment(echo bool) string
type WordBoundery ¶
type WordBoundery struct { BounderyType common.SpeechSynthesisBoundaryType AudioOffset float64 Duration float64 TextOffset uint WordLength uint Text string }
func (WordBoundery) String ¶
func (w WordBoundery) String() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.