GithubHelp home page GithubHelp logo

pocketsphinx-rs's Introduction

PocketSphinx

The pocketsphinx crate provides a safe wrapper around the native libpocketsphinx library.

Dependencies

In order to use the this crate, you must have the libpocketsphinx library installed where it can be found by pkg-config.

On Debian-based Linux distributions, install the libpocketsphinx1 package:

sudo apt-get install libpocketsphinx1

On OS X, install cmu-pocketsphinx with Homebrew:

brew install --HEAD cmu-sphinxbase
brew install --HEAD cmu-pocketsphinx

For building custom version of CMU PocketSphinx refer to official building documentation.

Usage

Add pocketsphinx as a dependency in Cargo.toml:

[dependencies]
pocketsphinx = "0.6.0"

Import the pocketsphinx crate, initialize PocketSphinx decoder:

let ps_config = try!(pocketsphinx::CmdLn::init(true, &["pocketsphinx",
    "-hmm", "data/cmusphinx-en-us-5.2",
    "-lm", "data/cmusphinx-5.0-en-us.lm",
    "-dict", "data/turtle.dic",
    ]));
let ps_decoder = pocketsphinx::PsDecoder::init(ps_config);

See PocketSphinx documentation to understand meaning of configuration parameters.

Start voice recognition:

try!(ps_decoder.start_utt(Some("utt_id")))
loop {
    let input_samples: &[i16] = read_audio();
    try!(ps_decoder.process_raw(input_samples, false, false));
    if (...) break;
}

Stop voice recognition and get result:

try!(ps_decoder.end_utt());
match ps_decoder.get_hyp() {
    None => println!("Not recognized"),
    Some((hyp, _utt_id, _score)) => println!("Recognized: {}", hyp),
}

License

Copyright © 2016 Mikhail Trishchenkov

Distributed under the MIT License.

Note: By using this crate, your executable will link to the libpocketsphinx C library, which is available under the simplified BSD license.

pocketsphinx-rs's People

Contributors

kriomant avatar nshmyrev avatar paspartout avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.