feat: 启用豆包二遍识别模式以提升实时性和准确率

- 切换到 bigmodel_async endpoint 并启用 enable_nonstream
- 第一遍流式识别提供实时文字预览
- VAD 分句后自动触发第二遍非流式识别提升准确率
- 修改文本处理逻辑从累加改为替换(适配 full 模式)
- 统一配置字段命名:app_key → app_id, access_key → access_token
This commit is contained in:
2026-03-01 21:34:54 +08:00
parent e4b5841c93
commit 8c7b9b45fd
7 changed files with 55 additions and 53 deletions

View File

@@ -6,8 +6,8 @@ import (
// DoubaoConfig holds 火山引擎豆包 ASR credentials.
type DoubaoConfig struct {
AppKey string `yaml:"app_key"`
AccessKey string `yaml:"access_key"`
AppID string `yaml:"app_id"`
AccessToken string `yaml:"access_token"`
ResourceID string `yaml:"resource_id"`
}

View File

@@ -41,11 +41,11 @@ func Load(configPath string) (Config, error) {
// applyEnv overrides config fields with environment variables.
func applyEnv(cfg *Config) {
if v := os.Getenv("DOUBAO_APP_KEY"); v != "" {
cfg.Doubao.AppKey = v
if v := os.Getenv("DOUBAO_APP_ID"); v != "" {
cfg.Doubao.AppID = v
}
if v := os.Getenv("DOUBAO_ACCESS_KEY"); v != "" {
cfg.Doubao.AccessKey = v
if v := os.Getenv("DOUBAO_ACCESS_TOKEN"); v != "" {
cfg.Doubao.AccessToken = v
}
if v := os.Getenv("DOUBAO_RESOURCE_ID"); v != "" {
cfg.Doubao.ResourceID = v
@@ -62,11 +62,11 @@ func applyEnv(cfg *Config) {
// validate checks required fields.
func validate(cfg Config) error {
if cfg.Doubao.AppKey == "" {
return fmt.Errorf("doubao.app_key is required (set DOUBAO_APP_KEY or config.yaml)")
if cfg.Doubao.AppID == "" {
return fmt.Errorf("doubao.app_id is required (set DOUBAO_APP_ID or config.yaml)")
}
if cfg.Doubao.AccessKey == "" {
return fmt.Errorf("doubao.access_key is required (set DOUBAO_ACCESS_KEY or config.yaml)")
if cfg.Doubao.AccessToken == "" {
return fmt.Errorf("doubao.access_token is required (set DOUBAO_ACCESS_TOKEN or config.yaml)")
}
return nil
}