Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 51e6844

Browse files
committed
Many changes
1 parent b2a4233 commit 51e6844

22 files changed

+350
-456
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ __pycache__
1111
*.htk
1212
*.lat
1313
*.fsg
14-
*.pyc
14+
*.pyc
15+
*.log
16+
sphinxbase/sphinxbase.py
17+
pocketsphinx/pocketsphinx.py

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
language: python
2+
sudo: false
3+
addons:
4+
apt:
5+
packages:
6+
- swig
27
python:
38
- '2.7'
49
- '3.2'
510
- '3.3'
611
- '3.4'
712
- '3.5'
8-
before_install:
9-
- sudo apt-get update -qq
10-
- sudo apt-get install -qq build-essential swig
11-
install:
12-
- python setup.py bdist_wheel build
13-
- pip install dist/pocketsphinx-*.whl
1413
script:
1514
- python setup.py test

LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 1999-2016 Carnegie Mellon University. All rights
2+
reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions
6+
are met:
7+
8+
1. Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in
13+
the documentation and/or other materials provided with the
14+
distribution.
15+
16+
This work was supported in part by funding from the Defense Advanced
17+
Research Projects Agency and the National Science Foundation of the
18+
United States of America, and the CMU Sphinx Speech Consortium.
19+
20+
THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
21+
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
24+
NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
prune build
2-
prune dist
3-
recursive-include sphinxbase/include *.h
4-
recursive-include sphinxbase/src *.c
5-
recursive-include sphinxbase/src *.h
6-
recursive-include sphinxbase/swig *.i
7-
prune sphinxbase/include/wince
8-
prune sphinxbase/include/android
9-
prune sphinxbase/src/sphinx_adtools
10-
prune sphinxbase/src/sphinx_cepview
11-
prune sphinxbase/src/sphinx_fe
12-
prune sphinxbase/src/sphinx_jsgf2fsg
13-
prune sphinxbase/src/sphinx_lmtools
14-
recursive-include pocketsphinx/include *.h
15-
recursive-include pocketsphinx/src *.c
16-
recursive-include pocketsphinx/src *.h
17-
recursive-include pocketsphinx/swig *.i
18-
prune pocketsphinx/src/gst-plugin
19-
prune pocketsphinx/src/programs
20-
include readme.md
21-
recursive-include include *.h
1+
recursive-include deps/sphinxbase/include *.h
2+
recursive-include deps/sphinxbase/src *.c
3+
recursive-include deps/sphinxbase/src *.h
4+
recursive-include deps/sphinxbase/swig *.i
5+
prune deps/sphinxbase/include/wince
6+
prune deps/sphinxbase/src/libsphinxad
7+
prune deps/sphinxbase/src/sphinx_adtools
8+
prune deps/sphinxbase/src/sphinx_cepview
9+
prune deps/sphinxbase/src/sphinx_fe
10+
prune deps/sphinxbase/src/sphinx_jsgf2fsg
11+
prune deps/sphinxbase/src/sphinx_lmtools
12+
recursive-include deps/pocketsphinx/include *.h
13+
recursive-include deps/pocketsphinx/src *.c
14+
recursive-include deps/pocketsphinx/src *.h
15+
recursive-include deps/pocketsphinx/swig *.i
16+
prune deps/pocketsphinx/src/gst-plugin
17+
prune deps/pocketsphinx/src/programs
18+
include README.rst
19+
include LICENSE

README.rst

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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>`__
File renamed without changes.

build.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
rm -rf venv2 venv3 build dist pocketsphinx.egg-info
4+
rm -rf sphinxbase/sphinxbase.py sphinxbase/*.so
5+
rm -rf pocketsphinx/pocketsphinx.py pocketsphinx/*.so
6+
7+
virtualenv -p /usr/bin/python2.7 venv2
8+
source venv2/bin/activate
9+
python setup.py sdist build
10+
python setup.py bdist_egg build
11+
python setup.py bdist_wheel build
12+
python setup.py sdist upload
13+
python setup.py bdist_egg upload
14+
python setup.py bdist_wheel upload
15+
deactivate
16+
17+
virtualenv -p /usr/bin/python3.5 venv3
18+
source venv3/bin/activate
19+
python setup.py bdist_egg build
20+
python setup.py bdist_wheel build
21+
python setup.py bdist_egg upload
22+
python setup.py bdist_wheel upload
23+
deactivate

example.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#!/usr/bin/env python
2-
from os import environ, path
2+
import os
33

4-
from pocketsphinx.pocketsphinx import *
5-
from sphinxbase.sphinxbase import *
4+
import sphinxbase as sb
5+
import pocketsphinx as ps
66

7-
MODELDIR = "pocketsphinx/model"
8-
DATADIR = "pocketsphinx/test/data"
7+
MODELDIR = 'deps/pocketsphinx/model'
8+
DATADIR = 'deps/pocketsphinx/test/data'
99

1010
# Create a decoder with certain model
11-
config = Decoder.default_config()
12-
config.set_string('-hmm', path.join(MODELDIR, 'en-us/en-us'))
13-
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
14-
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
15-
decoder = Decoder(config)
11+
config = ps.Decoder.default_config()
12+
config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us'))
13+
config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin'))
14+
config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
15+
config.set_string('-logfn', '/dev/null')
16+
decoder = ps.Decoder(config)
1617

1718
# Decode streaming data.
18-
decoder = Decoder(config)
1919
decoder.start_utt()
20-
stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
20+
stream = open(os.path.join(DATADIR, 'goforward.raw'), 'rb')
2121
while True:
22-
buf = stream.read(1024)
23-
if buf:
24-
decoder.process_raw(buf, False, False)
25-
else:
26-
break
22+
buf = stream.read(1024)
23+
if buf:
24+
decoder.process_raw(buf, False, False)
25+
else:
26+
break
2727
decoder.end_utt()
28-
print ('Best hypothesis segments: ', [seg.word for seg in decoder.seg()])
28+
stream.close()
29+
print('Best hypothesis segments:', [seg.word for seg in decoder.seg()])

0 commit comments

Comments
 (0)