speech

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleSpeechMessage

func HandleSpeechMessage(ctx context.Context, clientID, userID string, body json.RawMessage) error

HandleSpeechMessage 处理语音消息

Types

type Manager

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

Manager 语音识别会话管理器

var SessionManager *Manager

SessionManager 全局会话管理器

func NewManager

func NewManager() *Manager

NewManager 创建语音识别会话管理器

func (*Manager) CloseSession

func (m *Manager) CloseSession(ctx context.Context, clientID string) error

CloseSession 关闭语音识别会话

func (*Manager) CreateSession

func (m *Manager) CreateSession(ctx context.Context, clientID, userID string) (*Session, error)

CreateSession 创建语音识别会话

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, clientID string) (*Session, error)

GetSession 获取语音识别会话

func (*Manager) SendAudioData

func (m *Manager) SendAudioData(ctx context.Context, clientID string, data []byte) error

SendAudioData 发送音频数据

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 语音识别结果

Jump to

Keyboard shortcuts

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