python - python - 如何在模块pocketsphinx for python中调用模块pocketshinx?
问题描述
所以我试图在 pocketsphinx 模块文件夹中的 pocketsphinx.py 中使用一种方法,但它给了我一个错误:
ModuleNotFoundError:没有名为“pocketsphinx.pocketsphinx”的模块;'pocketsphinx' 不是一个包
我不知道发生了什么,因为它可以很好地为 sphinxbase 做同样的事情。并且“import pocketsphinx”可以工作,但没有输入我需要调用decoder_default_config的确切方法。这是代码:
import pyaudio as py
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import glob
import os, sys
model=(r'C:\Users\ellag\AppData\Local\Programs\Python\Python36\Lib\site-packages\pocketsphinx\model')
config = Decoder_default_config()
config.set_string('-hmm', os.path.join(model, 'en-us\en-us'))
config.set_string('-dict', os.path.join(model, 'en-us\cmuict-en-us.dict'))
config.set_string('-kws', os.path.join(model, 'kws_file'))
decoder = Decoder(config)
p = py.PyAudio()
stream = p.open(format=py.paInt16,channels=1,rate=16000,input=True)
stream.start_stream()
While True:
buf=stream.read(1024)
Decoder.process_raw(buf, False, False)
if Decoder.hyp() != None:
print(seg.word, seg.prob)
letter=seg.word()
解决方案
推荐阅读
- javascript - 在 Javascript 中实现 Gremlin / Janusgraph Websocket 客户端
- azure - Azure Ad B2B 身份验证从外部用户 CRM 检索数据
- google-bigquery - 标题未从 Google 大查询中的 Google 工作表中提取
- regex - 简化谷歌表格公式“SUM / INDEX / MATCH”
- java - 更改 PreferenceCategory 汇总字段颜色
- javascript - 将变量传递给自定义 Svelte Web 组件
- java - 将单元格合并到 MigLayout?
- javascript - 使用 observables 的老式回调同步
- google-cloud-platform - BigQuery 存储过程在插入数组时执行立即语句,插入不起作用
- java - 在Android中的服务活动中调用方法