You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Freeswitch中mod_unimrcp的ASR匹配及语法加载问题求助

Freeswitch语音识别问题排查与修复

一、问题根源分析

你遇到的Lua脚本语音匹配失败(返回001-no match)、JavaScript语法加载失败并报SyntaxError: missing ) after the argument list,核心原因是play_and_detect_speech的调用代码存在多处格式错误:

  • session.execute的参数未正确包裹在括号内,原代码将data=...写在括号外,属于基础语法错误
  • 音频路径/thilip/welcome.wav后缺少空格,导致detect:被识别为文件名的一部分,无法正确解析识别引擎参数
  • file://后多了空格,导致语法文件路径无效,无法加载sr.gram
  • 语句的引号、括号未闭合,直接触发JavaScript语法报错

Lua脚本中虽然能检测到语音,但因语法文件未正确加载,自然无法完成匹配,返回无匹配结果。

二、修复后的代码示例

修正后的Lua代码

session.execute("play_and_detect_speech", "/thilip/welcome.wav detect:unimrcp:uni2 {start-input-timers=false,no-input-timeout=5000,recognition-timeout=5000} file:///usr/local/freeswitch/grammar/sr.gram language=en-US;y=1;n=2")

修正后的JavaScript代码

session.execute("play_and_detect_speech", "/thilip/welcome.wav detect:unimrcp:uni2 {start-input-timers=false,no-input-timeout=5000,recognition-timeout=5000} file:///usr/local/freeswitch/grammar/sr.gram language=en-US;y=1;n=2");

三、额外排查要点

  • 确认sr.gram语法文件格式符合MRCP规范,规则逻辑、语言适配(en-US)是否正确
  • 检查mod_unimrcp配置,确保uni2通道的识别引擎连接正常,具备语法文件加载权限
  • 查看Freeswitch日志(如/var/log/freeswitch/freeswitch.log),获取语法加载、识别过程的详细错误信息

内容的提问来源于stack exchange,提问作者thilip an

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 11:40:32