Documentation
¶
Index ¶
- func HandleSpeechMessage(ctx context.Context, clientID, userID string, body json.RawMessage) error
- type Manager
- func (m *Manager) CloseSession(ctx context.Context, clientID string) error
- func (m *Manager) CreateSession(ctx context.Context, clientID, userID string) (*Session, error)
- func (m *Manager) GetSession(ctx context.Context, clientID string) (*Session, error)
- func (m *Manager) SendAudioData(ctx context.Context, clientID string, data []byte) error
- type Session
- type SpeechMessage
- type SpeechResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleSpeechMessage ¶
HandleSpeechMessage 处理语音消息
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 语音识别会话管理器
var SessionManager *Manager
SessionManager 全局会话管理器
func (*Manager) CloseSession ¶
CloseSession 关闭语音识别会话
func (*Manager) CreateSession ¶
CreateSession 创建语音识别会话
func (*Manager) GetSession ¶
GetSession 获取语音识别会话
type Session ¶
type Session struct {
ClientID string // 客户端ID
UserID string // 用户ID
Converter driver.SpeechTextConverter // 语音转文字服务
ResultChannel chan *driver.Text // 结果通道
ErrorChannel chan error // 错误通道
InitCompleteChan chan struct{} // 初始化完成通道
Active bool // 会话是否活跃
}
Session 语音识别会话
type SpeechMessage ¶
type SpeechMessage struct {
Action string `json:"action"` // 动作:start, data, stop
Data string `json:"data"` // Base64编码的音频数据
}
SpeechMessage WebSocket语音消息
type SpeechResult ¶
type SpeechResult struct {
Content string `json:"content"` // 识别文本
IsEnd bool `json:"is_end"` // 是否是最终结果
}
SpeechResult 语音识别结果
Click to show internal directories.
Click to hide internal directories.