refactor: 简化热词配置为豆包控制台 ID
- 移除本地热词列表配置,改为直接使用豆包控制台的热词表 ID - 删除 internal/asr/hotwords.go(不再需要本地解析) - 简化 client.go 逻辑,直接传递 boosting_table_id - 移除 protocol.go 中的 boosting_table_name 字段 - 更新配置示例,添加控制台链接说明 使用方法: 1. 在豆包控制台创建热词表:https://console.volcengine.com/speech/hotword 2. 复制热词表 ID 到 config.yaml 的 boosting_table_id 字段
This commit is contained in:
@@ -20,10 +20,10 @@ const (
|
||||
|
||||
// Config holds Doubao ASR connection parameters.
|
||||
type Config struct {
|
||||
AppID string
|
||||
AccessToken string
|
||||
ResourceID string
|
||||
Hotwords []string // 热词列表,格式 "词|权重" 或 "词"
|
||||
AppID string
|
||||
AccessToken string
|
||||
ResourceID string
|
||||
BoostingTableID string // 热词表 ID(从控制台创建)
|
||||
}
|
||||
|
||||
// Client manages a single ASR session with Doubao.
|
||||
@@ -58,21 +58,6 @@ func Dial(cfg Config, resultCh chan<- wsMsg.ServerMsg) (*Client, error) {
|
||||
closeCh: make(chan struct{}),
|
||||
log: slog.With("conn_id", connID),
|
||||
}
|
||||
// Parse hotwords configuration
|
||||
var boostingTableName string
|
||||
if len(cfg.Hotwords) > 0 {
|
||||
entries, err := ParseHotwords(cfg.Hotwords)
|
||||
if err != nil {
|
||||
slog.Warn("invalid hotwords config, skipping", "err", err)
|
||||
} else {
|
||||
boostingTableName = GenerateTableName(entries)
|
||||
tableContent := FormatHotwordsTable(entries)
|
||||
slog.Info("hotwords enabled",
|
||||
"count", len(entries),
|
||||
"table_name", boostingTableName,
|
||||
"content", tableContent)
|
||||
}
|
||||
}
|
||||
// Send FullClientRequest
|
||||
req := &FullClientRequest{
|
||||
User: UserMeta{UID: connID},
|
||||
@@ -84,15 +69,15 @@ func Dial(cfg Config, resultCh chan<- wsMsg.ServerMsg) (*Client, error) {
|
||||
Channel: 1,
|
||||
},
|
||||
Request: RequestMeta{
|
||||
ModelName: "seedasr-2.0",
|
||||
EnableITN: true,
|
||||
EnablePUNC: true,
|
||||
EnableDDC: true,
|
||||
ShowUtterances: true,
|
||||
ResultType: "full",
|
||||
EnableNonstream: true,
|
||||
EndWindowSize: 800,
|
||||
BoostingTableName: boostingTableName,
|
||||
ModelName: "seedasr-2.0",
|
||||
EnableITN: true,
|
||||
EnablePUNC: true,
|
||||
EnableDDC: true,
|
||||
ShowUtterances: true,
|
||||
ResultType: "full",
|
||||
EnableNonstream: true,
|
||||
EndWindowSize: 800,
|
||||
BoostingTableID: cfg.BoostingTableID,
|
||||
},
|
||||
}
|
||||
data, err := EncodeFullClientRequest(req)
|
||||
|
||||
Reference in New Issue
Block a user