Skip to content

[feature] bl speech recognize: support instant hotwords (--vocabulary) and context enhancement (--context) #188

Description

@Shyujikou

背景

bl speech recognize 接入字幕流水线时,需要提升专有名词(人名、地名、产品名、行业术语)的识别准确率。百炼语音识别提供三种提升方式(官方文档):

  1. 预编译热词 —— 预先创建词汇表,识别时传列表 ID(parameters.vocabulary_id)→ CLI 已支持(--vocabulary-id)✅
  2. 即时热词 —— 请求内联传 parameters.vocabulary{"词": 权重},权重 1–5 或 50 超级热词),无需预先建表 → CLI 未支持
  3. 上下文增强 —— 非实时识别在 input.context 传领域词表/对话历史(≤400 字符/轮),无需预先建表 → CLI 未支持

后两种适合字幕、会议纪要这类「词汇随每段音频变化、跨请求复用价值低」的临时性场景,且免费。目前 CLI 用户要么只用 --vocabulary-id(需先走热词管理 API 建表,且 bl 也没有热词列表管理命令),要么绕过 CLI 手写原始异步 API。

期望接口

bl speech recognize 上增加两个 flag(参数名以 DashScope 文档为准,以下为建议):

  • --vocabulary '{"Fendouzhe": 5, "whale necropolis": 4}' —— 即时热词,映射 parameters.vocabulary
  • --context '<领域词表文本>' —— 上下文增强,映射 input.contextuser/input_text 消息

已确认的技术事实

目标模型 qwen-audio-3.0-asr-flash-filetrans(华北2北京地域)同时支持即时热词与上下文增强。原始异步 API(POST /api/v1/services/audio/asr/transcription)实测可用:

{
  "model": "qwen-audio-3.0-asr-flash-filetrans",
  "input": {
    "file_urls": ["https://.../audio.m4a"],
    "context": [
      {"role": "user", "content": [{"type": "input_text", "text": "whale necropolis Fendouzhe Diamantina Zone beaked whale"}]}
    ]
  },
  "parameters": {
    "channel_id": [0],
    "language_hints": ["en"],
    "vocabulary": {"Fendouzhe": 5, "whale necropolis": 4}
  }
}

实测效果(同一段 8.5 分钟视频音频,仅对比是否携带上述参数):

专有名词 不带热词/上下文 带热词 + 上下文
Fendouzhe 被听成中文「奋斗者」 正确
Xiaotong 被听成 Zautong 正确
无空格连写段 多处(如 thentherearesurfacecurrents... 0 处

环境

  • CLI: bl 1.18.2
  • Skill: bailian-cli / bailian-gen / bailian-protocol 1.18.2
  • Node: v22.23.2
  • OS: macOS 26.6.2 (25G83)
  • Region: cn-beijing

相关

--vocabulary-id 需要先创建热词列表,但 bl 目前没有热词列表管理命令(创建/查询/删除 vocabulary)——是否也考虑补充(如 bl speech vocabulary)?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions