|
| 1 | +pocketsphinx-python |
| 2 | +=================== |
| 3 | + |
| 4 | +.. image:: https://img.shields.io/pypi/v/pocketsphinx.svg |
| 5 | + :target: https://pypi.python.org/pypi/pocketsphinx |
| 6 | + :alt: Latest Version |
| 7 | + |
| 8 | +.. image:: https://img.shields.io/pypi/status/pocketsphinx.svg |
| 9 | + :target: https://pypi.python.org/pypi/pocketsphinx |
| 10 | + :alt: Development Status |
| 11 | + |
| 12 | +.. image:: https://img.shields.io/pypi/pyversions/pocketsphinx.svg |
| 13 | + :target: https://pypi.python.org/pypi/pocketsphinx |
| 14 | + :alt: Supported Python Versions |
| 15 | + |
| 16 | +.. image:: https://travis-ci.org/bambocher/pocketsphinx-python.svg?branch=master |
| 17 | + :target: https://travis-ci.org/bambocher/pocketsphinx-python |
| 18 | + :alt: Build Status |
| 19 | + |
| 20 | +.. image:: https://img.shields.io/pypi/l/pocketsphinx.svg |
| 21 | + :target: https://pypi.python.org/pypi/pocketsphinx |
| 22 | + :alt: License |
| 23 | + |
| 24 | +Python interface to CMU SphinxBase and PocketSphinx libraries created with SWIG. |
| 25 | +Pocketsphinx packages include python support, however, it is based on Automake and not well supported on Windows. |
| 26 | + |
| 27 | +This package provides module created with Python distutils setup and can be more portable. |
| 28 | + |
| 29 | +Supported Platforms |
| 30 | +------------------- |
| 31 | + |
| 32 | +* Windows 7 |
| 33 | +* Windows 8 |
| 34 | +* Ubuntu 14.04 |
| 35 | + |
| 36 | +Install on Windows |
| 37 | +------------------ |
| 38 | + |
| 39 | +Requirements |
| 40 | +~~~~~~~~~~~~ |
| 41 | + |
| 42 | +* `Python <http://aka.ms/vcpython27>`__ |
| 43 | +* `git <http://git-scm.com/downloads>`__ |
| 44 | +* `Swig <http://www.swig.org/download.html>`__ |
| 45 | +* `Microsoft Visual C++ Compiler for Python 2.7 <http://aka.ms/vcpython27>`__ |
| 46 | + |
| 47 | +Install |
| 48 | +~~~~~~~ |
| 49 | + |
| 50 | + .. code:: bash |
| 51 | + pip install pocketsphinx |
| 52 | +
|
| 53 | +or |
| 54 | + |
| 55 | + .. code:: bash |
| 56 | + git clone --recursive https://github.com/bambocher/pocketsphinx-python |
| 57 | + cd pocketsphinx-python |
| 58 | + python setup.py install |
| 59 | +
|
| 60 | +Install on Ubuntu |
| 61 | +----------------- |
| 62 | + |
| 63 | +Requirements |
| 64 | +~~~~~~~~~~~~ |
| 65 | + |
| 66 | +* python |
| 67 | +* python-dev |
| 68 | +* python-pip |
| 69 | +* build-essential |
| 70 | +* swig |
| 71 | +* git |
| 72 | + |
| 73 | +Install |
| 74 | +~~~~~~~ |
| 75 | + |
| 76 | + .. code:: bash |
| 77 | + sudo apt-get install -qq python python-dev python-pip build-essential swig |
| 78 | + sudo pip install pocketsphinx |
| 79 | +
|
| 80 | +or |
| 81 | + |
| 82 | + .. code:: bash |
| 83 | + sudo apt-get install -qq python python-dev python-pip build-essential swig git |
| 84 | + git clone --recursive https://github.com/bambocher/pocketsphinx-python |
| 85 | + cd pocketsphinx-python |
| 86 | + sudo python setup.py install |
| 87 | +
|
| 88 | +Basic usage |
| 89 | +----------- |
| 90 | + |
| 91 | + .. code:: python |
| 92 | + #!/usr/bin/env python |
| 93 | + import os |
| 94 | +
|
| 95 | + import sphinxbase as sb |
| 96 | + import pocketsphinx as ps |
| 97 | +
|
| 98 | + MODELDIR = 'deps/pocketsphinx/model' |
| 99 | + DATADIR = 'deps/pocketsphinx/test/data' |
| 100 | +
|
| 101 | + # Create a decoder with certain model |
| 102 | + config = ps.Decoder.default_config() |
| 103 | + config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us')) |
| 104 | + config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin')) |
| 105 | + config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict')) |
| 106 | + config.set_string('-logfn', '/dev/null') |
| 107 | + decoder = ps.Decoder(config) |
| 108 | +
|
| 109 | + # Decode streaming data. |
| 110 | + decoder.start_utt() |
| 111 | + stream = open(os.path.join(DATADIR, 'goforward.raw'), 'rb') |
| 112 | + while True: |
| 113 | + buf = stream.read(1024) |
| 114 | + if buf: |
| 115 | + decoder.process_raw(buf, False, False) |
| 116 | + else: |
| 117 | + break |
| 118 | + decoder.end_utt() |
| 119 | + stream.close() |
| 120 | + print('Best hypothesis segments:', [seg.word for seg in decoder.seg()]) |
| 121 | +
|
| 122 | +License |
| 123 | +------- |
| 124 | + |
| 125 | +`The BSD License <https://github.com/bambocher/pocketsphinx-python/blob/master/LICENSE>`__ |
0 commit comments