Files
voicepaste/internal/config/config.go
imbytecat 4120d6451e 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 字段
2026-03-02 01:16:34 +08:00

61 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
import (
"sync/atomic"
)
// DoubaoConfig holds 火山引擎豆包 ASR credentials.
type DoubaoConfig struct {
AppID string `yaml:"app_id"`
AccessToken string `yaml:"access_token"`
ResourceID string `yaml:"resource_id"`
BoostingTableID string `yaml:"boosting_table_id"` // 热词表 ID从控制台创建
}
// SecurityConfig holds authentication settings.
type SecurityConfig struct {
Token string `yaml:"token"`
}
// ServerConfig holds server settings.
type ServerConfig struct {
Port int `yaml:"port"`
TLSAuto bool `yaml:"tls_auto"`
}
// Config is the top-level configuration.
type Config struct {
Doubao DoubaoConfig `yaml:"doubao"`
Server ServerConfig `yaml:"server"`
Security SecurityConfig `yaml:"security"`
}
// defaults returns a Config with default values.
func defaults() Config {
return Config{
Doubao: DoubaoConfig{
ResourceID: "volc.seedasr.sauc.duration",
},
Server: ServerConfig{
Port: 8443,
TLSAuto: true,
},
}
}
// global holds the current config atomically for concurrent reads.
var global atomic.Value
// Get returns the current config snapshot. Safe for concurrent use.
func Get() Config {
if v := global.Load(); v != nil {
return v.(Config)
}
return defaults()
}
// store updates the global config.
func store(cfg Config) {
global.Store(cfg)
}