首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >语音识别和python入门

语音识别和python入门
EN

Stack Overflow用户
提问于 2012-09-03 03:31:59
回答 7查看 80.7K关注 0票数 26

我想知道从哪里可以开始语音识别。不是使用库或任何相当“黑盒”的东西,而是我想知道在哪里可以真正创建一个简单的语音识别脚本。我做了一些搜索,发现并不多,但我看到的是,有‘声音’或音节的字典,可以拼凑成文本。所以基本上我的问题是我可以从哪里开始呢?

此外,由于这有点乐观,我也可以(目前)在我的程序中使用一个库。我看到一些speech to text库和API只输出一个结果。这是可以的,但它将是不现实的。我当前的程序已经检查了输入的任何文本的语法和所有内容,因此,如果我有语音转文本软件的前十个结果,那么它可以检查每个结果,并排除任何没有意义的结果。

EN

回答 7

Stack Overflow用户

回答已采纳

发布于 2013-05-15 03:33:46

更新:这不再起作用了

因为谷歌关闭了它的平台

--

您可以使用https://pypi.python.org/pypi/pygsr

代码语言:javascript
复制
$> pip install pygsr

示例用法:

代码语言:javascript
复制
from pygsr import Pygsr
speech = Pygsr()
# duration in seconds
speech.record(3)
# select the language
phrase, complete_response = speech.speech_to_text('en_US')

print phrase
票数 7
EN

Stack Overflow用户

发布于 2012-09-03 05:38:23

如果你真的想从头开始理解语音识别,那就去找一个很好的python信号处理包,然后独立阅读语音识别软件吧。

但语音识别是一个极其复杂的问题(主要是因为当我们说话时,声音会以各种方式相互作用)。即使你从你能得到的最好的语音识别库开始,你也不会发现自己无事可做。

票数 7
EN

Stack Overflow用户

发布于 2014-06-24 01:05:22

Pocketsphinx也是一个很好的选择。SWIG提供了Python绑定,可以轻松地将其集成到脚本中。

例如:

代码语言:javascript
复制
from os import environ, path
from itertools import izip

from pocketsphinx import *
from sphinxbase import *

MODELDIR = "../../../model"
DATADIR = "../../../test/data"

# Create a decoder with certain model
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'hmm/en_US/hub4wsj_sc_8k'))
config.set_string('-lm', path.join(MODELDIR, 'lm/en_US/hub4.5000.DMP'))
config.set_string('-dict', path.join(MODELDIR, 'lm/en_US/hub4.5000.dic'))
decoder = Decoder(config)

# Decode static file.
decoder.decode_raw(open(path.join(DATADIR, 'goforward.raw'), 'rb'))

# Retrieve hypothesis.
hypothesis = decoder.hyp()
print 'Best hypothesis: ', hypothesis.best_score, hypothesis.hypstr

print 'Best hypothesis segments: ', [seg.word for seg in decoder.seg()]

# Access N best decodings.
print 'Best 10 hypothesis: '
for best, i in izip(decoder.nbest(), range(10)):
    print best.hyp().best_score, best.hyp().hypstr

# Decode streaming data.
decoder = Decoder(config)
decoder.start_utt('goforward')
stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
    buf = stream.read(1024)
    if buf:
        decoder.process_raw(buf, False, False)
    else:
        break
decoder.end_utt()
print 'Stream decoding result:', decoder.hyp().hypstr
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12239080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档