1 Star 0 Fork 1

Yihui Xiong / pocketsphinx-python

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

pocketsphinx-python

Build Status

Python interface to CMU SphinxBase and PocketSphinx libraries created with SWIG. Pocketsphinx packages include python support, however, it is based on Automake and not well supported on Windows.

This package provides module created with Python distutils setup and can be more portable.

Supported Platforms

  • Windows 7
  • Windows 8
  • Ubuntu 14.10

Install on Windows

Dependencies

Install

pip install pocketsphinx

or

git clone --recursive https://github.com/bambocher/pocketsphinx-python
cd pocketsphinx-python
python setup.py install

Install on Ubuntu

Dependencies

  • python
  • python-dev
  • python-pip
  • build-essential
  • swig
  • git

Install

sudo apt-get install -y python python-dev python-pip build-essential swig git
sudo pip install pocketsphinx

or

sudo apt-get install -y python python-dev python-pip build-essential swig git
git clone --recursive https://github.com/bambocher/pocketsphinx-python
cd pocketsphinx-python
sudo python setup.py install

Basic usage

#!/usr/bin/env python
from os import environ, path

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *

MODELDIR = "pocketsphinx/model"
DATADIR = "pocketsphinx/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('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = Decoder(config)

# 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()
print ('Best hypothesis segments: ', [seg.word for seg in decoder.seg()])

Comments ( 0 )

Sign in for post a comment

About

Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://git.oschina.net/yihui/pocketsphinx-python.git
git@git.oschina.net:yihui/pocketsphinx-python.git
yihui
pocketsphinx-python
pocketsphinx-python
master

Search