将声音转换为 python 中的音素列表

convert sound to list of phonemes in python

如何将任何声音信号转换为列表音素?

即实际方法 and/or 从数字信号到录音所依据的音素列表的代码。
例如:

lPhonemes = audio_to_phonemes(aSignal)

例如

from scipy.io.wavfile import read
iSampleRate, aSignal = read(sRecordingDir)

aSignal = #numpy array for the recorded word 'hear'
lPhonemes = ['HH', 'IY1', 'R']

我需要函数audio_to_phonemes

并不是所有的声音都是语言词,所以我不能只用something that uses the google API举例。

编辑
我不想要音频到单词,我想要音频到音素。大多数图书馆似乎都没有输出。您推荐的任何库都需要能够输出组成声音的音素的有序列表。它需要在 python.

我也很想知道声音到音素的过程是如何进行的。如果不是为了实现目的,那么为了利益。

I need to create the function audio_to_phonemes

你基本上是在说:

I need to re-implement 40 years of speech recognition research

您不应该自己实现它(除非您即将成为语音识别领域的教授并且拥有革命性的新方法),而应该使用许多现有框架中的一个。看看 sphinx / pocketsphinx!

准确的音素识别并不容易实现,因为音素本身的定义相当松散。即使在良好的音频中,当今最好的系统也有大约 18% 的音素错误率(您可以在 Alex Graves 发布的 TIMIT 上查看 LSTM-RNN 结果)。

在CMUSphinx中Python的音素识别是这样完成的:

from os import environ, path

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *

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

# Create a decoder with certain model
config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-allphone', path.join(MODELDIR, 'en-us/en-us-phone.lm.dmp'))
config.set_float('-lw', 2.0)
config.set_float('-beam', 1e-10)
config.set_float('-pbeam', 1e-10)

# Decode streaming data.
decoder = Decoder(config)

decoder.start_utt()
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()

hypothesis = decoder.hyp()
print ('Phonemes: ', [seg.word for seg in decoder.seg()])

您需要从 github 查看最新的 pocketsphinx 才能 运行 这个例子。结果应如下所示:

  ('Best phonemes: ', ['SIL', 'G', 'OW', 'F', 'AO', 'R', 'W', 'ER', 'D', 'T', 'AE', 'N', 'NG', 'IY', 'IH', 'ZH', 'ER', 'Z', 'S', 'V', 'SIL'])

另见 wiki page

看看 Allosaurus,一个通用的(~2000 语言)phone 识别器给你 IPA phonemes。在示例波形文件中,我确实下载了最新模型并在 Python3.

中进行了尝试
$ python -m allosaurus.bin.download_model -m latest
$ python -m allosaurus.run -i sample.wav
æ l u s ɔ ɹ s