Files
voicepaste/internal/config/config.go
imbytecat b786d9f90b feat: 实现本地热词管理,移除平台绑定
- 使用 corpus.context 参数直接传递热词列表(豆包文档支持)
- 移除 boosting_table_id 配置,避免绑定火山引擎控制台
- 实现 BuildHotwordsContext 函数,将本地热词转换为 JSON 格式
- 热词配置完全本地化,便于迁移到其他 ASR 平台

配置示例:
  hotwords:
    - 张三
    - 李四
    - VoicePaste

程序自动转换为豆包 API 要求的格式:
{"hotwords":[{"word":"张三"},{"word":"李四"},{"word":"VoicePaste"}]}
2026-03-02 01:36:14 +08:00

61 lines
1.3 KiB
Go

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"`
Hotwords []string `yaml:"hotwords"` // 本地热词列表
}
// 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)
}