40760aa884
- server:Go 网关(WS 流式识别中继/计费配额/微信登录支付 mock/反馈/埋点),gummy provider 已真实联调 - desktop:Tauri 2(全局快捷键 push-to-talk/浮层/托盘/设置/登录购买/反馈/首启引导) - android:Compose 主 App + IME(键盘内录音直传) - ios:App + 键盘扩展(1A spike 实证键盘内不可录音,走 deep link 听写) - design/design-pipeline:设计系统 + token 导出 iOS/Android 主题 - doc:前后端设计文档(HTML);web:官网宣传页;todo:任务看板 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
35 lines
989 B
Go
35 lines
989 B
Go
// Package asr 流式识别 Provider 抽象:网关只依赖此接口,gummy / volcano / mock 可切换。
|
||
package asr
|
||
|
||
import "context"
|
||
|
||
type SessionConfig struct {
|
||
SampleRate int
|
||
// SessionID 仅用于日志关联
|
||
SessionID string
|
||
}
|
||
|
||
type Result struct {
|
||
Text string
|
||
IsFinal bool
|
||
// EndTimeMs Provider 报告的本句结束时间(相对会话起点,毫秒);0=未提供。
|
||
// 网关用它与实收帧累计时长做计量交叉校验。
|
||
EndTimeMs int64
|
||
// Err 非空表示会话级错误,随后 Results 通道关闭
|
||
Err error
|
||
}
|
||
|
||
type Session interface {
|
||
// SendAudio 推一帧 PCM(100ms / 3200B)
|
||
SendAudio(pcm []byte) error
|
||
// Results 识别结果通道;会话结束(Close 或上游完成)后关闭
|
||
Results() <-chan Result
|
||
// Close 结束会话:要求上游 flush 尾部音频并下发最终 final 后关闭通道
|
||
Close() error
|
||
}
|
||
|
||
type Provider interface {
|
||
Name() string
|
||
StartSession(ctx context.Context, cfg SessionConfig) (Session, error)
|
||
}
|