| | from pocketsphinx import LiveSpeech |
| | for phrase in LiveSpeech(): print(phrase) |
| | from pocketsphinx import LiveSpeech |
| |
|
| | speech = LiveSpeech(lm=False, keyphrase='forward', kws_threshold=1e-20) |
| | for phrase in speech: |
| | print(phrase.segments(detailed=True)) |
| |
|
| | import os |
| | from pocketsphinx import LiveSpeech, get_model_path |
| |
|
| | model_path = get_model_path() |
| |
|
| | speech = LiveSpeech( |
| | verbose=False, |
| | sampling_rate=16000, |
| | buffer_size=2048, |
| | no_search=False, |
| | full_utt=False, |
| | hmm=os.path.join(model_path, 'en-us'), |
| | lm=os.path.join(model_path, 'en-us.lm.bin'), |
| | dic=os.path.join(model_path, 'cmudict-en-us.dict') |
| | ) |
| |
|
| | for phrase in speech: |
| | print(phrase) |
| |
|
| | from pocketsphinx import AudioFile |
| | for phrase in AudioFile(): print(phrase) |
| |
|
| | from pocketsphinx import AudioFile |
| |
|
| | audio = AudioFile(lm=False, keyphrase='forward', kws_threshold=1e-20) |
| | for phrase in audio: |
| | print(phrase.segments(detailed=True)) |
| |
|
| | import os |
| | from pocketsphinx import AudioFile, get_model_path, get_data_path |
| |
|
| | model_path = get_model_path() |
| | data_path = get_data_path() |
| |
|
| | config = { |
| | 'verbose': False, |
| | 'audio_file': os.path.join(data_path, 'goforward.raw'), |
| | 'buffer_size': 2048, |
| | 'no_search': False, |
| | 'full_utt': False, |
| | 'hmm': os.path.join(model_path, 'en-us'), |
| | 'lm': os.path.join(model_path, 'en-us.lm.bin'), |
| | 'dict': os.path.join(model_path, 'cmudict-en-us.dict') |
| | } |
| |
|
| | audio = AudioFile(**config) |
| | for phrase in audio: |
| | print(phrase) |
| |
|
| |
|
| | from pocketsphinx import AudioFile |
| |
|
| | |
| | fps = 100 |
| |
|
| | for phrase in AudioFile(frate=fps): |
| | print('-' * 28) |
| | print('| %5s | %3s | %4s |' % ('start', 'end', 'word')) |
| | print('-' * 28) |
| | for s in phrase.seg(): |
| | print('| %4ss | %4ss | %8s |' % (s.start_frame / fps, s.end_frame / fps, s.word)) |
| | print('-' * 28) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | from pocketsphinx import Pocketsphinx |
| | print(Pocketsphinx().decode()) |
| |
|
| |
|
| |
|
| | from __future__ import print_function |
| | import os |
| | from pocketsphinx import Pocketsphinx, get_model_path, get_data_path |
| |
|
| | model_path = get_model_path() |
| | data_path = get_data_path() |
| |
|
| | config = { |
| | 'hmm': os.path.join(model_path, 'en-us'), |
| | 'lm': os.path.join(model_path, 'en-us.lm.bin'), |
| | 'dict': os.path.join(model_path, 'cmudict-en-us.dict') |
| | } |
| |
|
| | ps = Pocketsphinx(**config) |
| | ps.decode( |
| | audio_file=os.path.join(data_path, 'goforward.raw'), |
| | buffer_size=2048, |
| | no_search=False, |
| | full_utt=False |
| | ) |
| |
|
| | print(ps.segments()) |
| | print('Detailed segments:', *ps.segments(detailed=True), sep='\n') |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | print(ps.hypothesis()) |
| | print(ps.probability()) |
| | print(ps.score()) |
| | print(ps.confidence()) |
| |
|
| | print(*ps.best(count=10), sep='\n') |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | from pocketsphinx import Pocketsphinx |
| |
|
| | ps = Pocketsphinx(verbose=True) |
| | ps.decode() |
| |
|
| | print(ps.hypothesis()) |
| |
|
| |
|
| | from pocketsphinx import Pocketsphinx |
| |
|
| | ps = Pocketsphinx(verbose=True, logfn='pocketsphinx.log') |
| | ps.decode() |
| |
|
| | print(ps.hypothesis()) |
| |
|
| | import os |
| | from pocketsphinx import DefaultConfig, Decoder, get_model_path, get_data_path |
| |
|
| | model_path = get_model_path() |
| | data_path = get_data_path() |
| |
|
| | |
| | config = DefaultConfig() |
| | config.set_string('-hmm', os.path.join(model_path, 'en-us')) |
| | config.set_string('-lm', os.path.join(model_path, 'en-us.lm.bin')) |
| | config.set_string('-dict', os.path.join(model_path, 'cmudict-en-us.dict')) |
| | decoder = Decoder(config) |
| |
|
| | |
| | buf = bytearray(1024) |
| | with open(os.path.join(data_path, 'goforward.raw'), 'rb') as f: |
| | decoder.start_utt() |
| | while f.readinto(buf): |
| | decoder.process_raw(buf, False, False) |
| | decoder.end_utt() |
| | print('Best hypothesis segments:', [seg.word for seg in decoder.seg()]) |
| |
|