如何检测唤醒词或是否说出任何单词

时间:2019-07-11 18:17:20

标签: python pocketsphinx

无法找到一种运行Pocketsphinx包装器的方法,该方法应该可以轻松地知道说了哪些单词

所提供的一些代码看起来很像这样

from pocketsphinx import LiveSpeech

speech = LiveSpeech(lm=False, keyphrase='forward', kws_threshold=1e-20)
for phrase in speech:
    print(phrase.segments(detailed=True))

但是没有任何效果,我的终端输出实际上什么也没说。只是空白。如何检测任何唤醒词?

1 个答案:

答案 0 :(得分:1)

我的解决方法是使运行Pocketsphinx的命令进入子进程并将输出通过管道传递到我的python脚本中。

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             Title="Safe Area"
             ios:Page.UseSafeArea="true">
    <StackLayout>
        ...
    </StackLayout>
</ContentPage>

显示“ print line.upper()”的行在终端中看起来像

import subprocess
p = subprocess.Popen("pocketsphinx_continuous -inmic yes", stdout=subprocess.PIPE, bufsize=1, shell=True)
for line in iter(p.stdout.readline, b''):
    print line.upper(),
p.stdout.close()
p.wait()

这是实时的!

相关问题