语音中的关键词识别

发布于 2024-10-20 04:29:42 字数 1539 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神回复 2024-10-27 04:29:42

CMUSphinx 在 pocketsphinx 引擎中实现关键字识别,详细信息请参见 常见问题解答条目。

要识别单个关键词,您可以在“关键词搜索”模式下运行解码器。

从命令行尝试:

pocketsphinx_continuous -infile file.wav -keyphrase “oh mighty computer” -kws_threshold 1e-20

从代码:

 ps_set_keyphrase(ps, "keyphrase_search", "oh mighty computer");
 ps_set_search(ps, "keyphrase_search);
 ps_start_utt();
 /* process data */

您还可以在我们的源代码中找到 Python 和 Android/Java 的示例。 Python 代码如下所示,完整示例此处

# Process audio chunk by chunk. On keyphrase detected perform action and restart search
decoder = Decoder(config)
decoder.start_utt()
while True:
    buf = stream.read(1024)
    if buf:
         decoder.process_raw(buf, False, False)
    else:
         break
    if decoder.hyp() != None:
        print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
        print ("Detected keyphrase, restarting search")
        decoder.end_utt()
        decoder.start_utt()

必须针对测试数据上的每个关键短语调整阈值,以获得漏检和误报之间的适当平衡。您可以尝试 1e-5 到 1e-50 等值。

为了获得最佳准确性,最好使用 3-4 个音节的关键短语。太短的短语很容易混淆。

您还可以搜索多个关键词,创建一个文件 keyphrase.list,如下所示:

  oh mighty computer /1e-40/
  hello world /1e-30/
  other_phrase /other_phrase_threshold/

并在带有 -kws 配置选项的解码器中使用它。

  pocketsphinx_continuous -inmic yes -kws keyphrase_list

sphinx4 解码器尚未实现此功能。

CMUSphinx implements keyword spotting in pocketsphinx engine, see for details the FAQ entry.

To recognize a single keyphrase you can run decoder in “keyphrase search” mode.

From command line try:

pocketsphinx_continuous -infile file.wav -keyphrase “oh mighty computer” -kws_threshold 1e-20

From the code:

 ps_set_keyphrase(ps, "keyphrase_search", "oh mighty computer");
 ps_set_search(ps, "keyphrase_search);
 ps_start_utt();
 /* process data */

You can also find examples for Python and Android/Java in our sources. Python code looks like this, full example here:

# Process audio chunk by chunk. On keyphrase detected perform action and restart search
decoder = Decoder(config)
decoder.start_utt()
while True:
    buf = stream.read(1024)
    if buf:
         decoder.process_raw(buf, False, False)
    else:
         break
    if decoder.hyp() != None:
        print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
        print ("Detected keyphrase, restarting search")
        decoder.end_utt()
        decoder.start_utt()

Threshold must be tuned for every keyphrase on a test data to get the right balance missed detections and false alarms. You can try values like 1e-5 to 1e-50.

For the best accuracy it is better to have keyphrase with 3-4 syllables. Too short phrases are easily confused.

You can also search for multiple keyphrase, create a file keyphrase.list like this:

  oh mighty computer /1e-40/
  hello world /1e-30/
  other_phrase /other_phrase_threshold/

And use it in decoder with -kws configuration option.

  pocketsphinx_continuous -inmic yes -kws keyphrase_list

This feature is not yet implemented in sphinx4 decoder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文