convert sound to list of phonemes in python

前端 未结 3 662
清酒与你
清酒与你 2020-12-28 09:00

How do I convert any sound signal to a list phonemes?

I.e the actual methodology and/or code to go from a digital signal to a list of phonemes that the sound recor

3条回答
  •  礼貌的吻别
    2020-12-28 09:44

    Accurate phoneme recognition is not easy to archive because phonemes itself are pretty loosely defined. Even in good audio the best possible systems today have about 18% phoneme error rate (you can check LSTM-RNN results on TIMIT published by Alex Graves).

    In CMUSphinx phoneme recognition in Python is done like this:

    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()])
    

    You need to checkout latest pocketsphinx from github in order to run this example. Result should look like this:

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

    See also the wiki page

提交回复
热议问题