cmusphinx / pocketsphinx

A small speech recognizer
Other
3.87k stars 713 forks source link

What is AlignmentEntry? #340

Closed zyh3826 closed 1 year ago

zyh3826 commented 1 year ago

Hi, thanks for your work, it's really nice. I use the code below to run an alignment:

with wave.open(args.audio, "rb") as audio:
    data = audio.getfp().read()
    decoder = Decoder(samprate=audio.getframerate())
    decoder.set_align_text(args.text)
    decoder.start_utt()
    decoder.process_raw(data, full_utt=True)
    decoder.end_utt()
    decoder.set_alignment()
    decoder.start_utt()
    decoder.process_raw(data, full_utt=True)
    decoder.end_utt()
    for word in decoder.get_alignment():
        print(list(word))

the result is an AlignmentEntry object, how can I find documents of this object? What are its attributions? Can't find it in your documents. image

thanks a lot.

zyh3826 commented 1 year ago

I also try this, get the same results:

for word in decoder.get_alignment():
        for phone in word:
            for state in phone:
                print(word, phone, state)

image

dhdaines commented 1 year ago

Hi! Sorry for the long time to reply, I am just catching up on PocketSphinx-related stuff now.

As it turns out the AlignmentEntry should be documented, but was accidentally left out of the online documentation - I will fix this in the next release, shortly. You can see its documentation by running python -m pydoc pocketsphinx._pocketsphinx.AlignmentEntry

See also its docstring here: https://github.com/cmusphinx/pocketsphinx/blob/master/cython/_pocketsphinx.pyx#L1992

zyh3826 commented 1 year ago

Got it, thanks for your reply