I have made a couple mods to the hellow world tutorial. 1. more on troubleshooting errors on the first minimal hello_ps, program, and 2. Better output on the full hello_ps program. Attached is the updated file. Renamed as a text file.
<!DOCTYPE html>
<html dir="ltr" class="js desktop" lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Building application with pocketsphinx [CMUSphinx Wiki]</title>
<script src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/ga.js" async="" type="text/javascript"></script><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<meta name="generator" content="DokuWiki">
<meta name="robots" content="index,follow">
<meta name="keywords" content="tutorialpocketsphinx">
<link rel="search" type="application/opensearchdescription+xml" href="http://cmusphinx.sourceforge.net/wiki/lib/exe/opensearch.php" title="CMUSphinx Wiki">
<link rel="start" href="http://cmusphinx.sourceforge.net/wiki/">
<link rel="contents" href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=index" title="Sitemap">
<link rel="alternate" type="application/rss+xml" title="Recent changes" href="http://cmusphinx.sourceforge.net/wiki/feed.php">
<link rel="alternate" type="application/rss+xml" title="Current namespace" href="http://cmusphinx.sourceforge.net/wiki/feed.php?mode=list&ns=">
<link rel="alternate" type="text/html" title="Plain HTML" href="http://cmusphinx.sourceforge.net/wiki/_export/xhtml/tutorialpocketsphinx">
<link rel="alternate" type="text/plain" title="Wiki Markup" href="http://cmusphinx.sourceforge.net/wiki/_export/raw/tutorialpocketsphinx">
<link rel="canonical" href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx">
<link rel="stylesheet" type="text/css" href="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/css.css">
<script type="text/javascript">/*<![CDATA[*/var NS='';var JSINFO = {"id":"tutorialpocketsphinx","namespace":""};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/js.php"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon" href="http://cmusphinx.sourceforge.net/wiki/lib/tpl/cmusphinx/images/favicon.ico">
<link rel="apple-touch-icon" href="http://cmusphinx.sourceforge.net/wiki/lib/tpl/cmusphinx/images/apple-touch-icon.png">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-11921517-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!--[if lte IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]-->
<div id="dokuwiki__site"><div id="dokuwiki__top" class="site dokuwiki mode_show tpl_cmusphinx ">
<!-- ********** HEADER ********** -->
<div id="dokuwiki__header"><div class="pad group">
<div class="headings group">
<ul class="a11y skip">
<li><a href="#dokuwiki__content">skip to content</a></li>
</ul>
<h1>
<span><a href="http://cmusphinx.sourceforge.net/">CMUSphinx</a></span>
</h1>
</div>
<div class="tools group">
<!-- USER TOOLS -->
<div id="dokuwiki__usertools">
<h3 class="a11y">User Tools</h3>
<ul>
<li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=login&sectok=d9da7c09a312e2fc43b8c561830fa325" class="action login" rel="nofollow" title="Login">Login</a></li> </ul>
</div>
<!-- SITE TOOLS -->
<div id="dokuwiki__sitetools">
<h3 class="a11y">Site Tools</h3>
<form action="/wiki/start" accept-charset="utf-8" class="search" id="dw__search" method="get" role="search"><div class="no"><input name="do" value="search" type="hidden"><input id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" type="text"><input value="Search" class="button" title="Search" type="submit"><div style="display: none;" id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form> <div class="mobileTools">
<form action="/wiki/doku.php" method="get" accept-charset="utf-8"><div class="no"><input name="id" value="tutorialpocketsphinx" type="hidden"><select name="do" class="edit quickselect" title="Tools"><option selected="selected" value="">Tools</option><optgroup label="Page Tools"><option value="edit">Show pagesource</option><option value="revisions">Old revisions</option><option value="backlink">Backlinks</option></optgroup><optgroup label="Site Tools"><option value="recent">Recent changes</option><option value="media">Media Manager</option><option value="index">Sitemap</option></optgroup><optgroup label="User Tools"><option value="login">Login</option></optgroup></select><input style="display: none;" value=">" type="submit"></div></form> </div>
<ul>
<li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=recent" class="action recent" accesskey="r" rel="nofollow" title="Recent changes [R]">Recent changes</a></li><li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=media&ns=" class="action media" rel="nofollow" title="Media Manager">Media Manager</a></li><li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=index" class="action index" accesskey="x" rel="nofollow" title="Sitemap [X]">Sitemap</a></li> </ul>
</div>
</div>
<div class="nav-menu">
<ul>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki/download">Download</a></li>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki/tutorial">Tutorial</a></li>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki">Wiki</a></li>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki/develop">Develop</a></li>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki/research">Research</a></li>
<li class="page-item"><a href="http://cmusphinx.sourceforge.net/wiki/about">About</a></li>
</ul>
</div>
<!-- BREADCRUMBS -->
<div class="breadcrumbs">
<div class="trace"><span class="bchead">Trace:</span> <span class="bcsep">โข</span> <bdi><a href="http://cmusphinx.sourceforge.net/wiki/start" class="breadcrumbs" title="start">CMUSphinx Wiki</a></bdi> <span class="bcsep">โข</span> <bdi><a href="http://cmusphinx.sourceforge.net/wiki/tutorial" class="breadcrumbs" title="tutorial">CMUSphinx Tutorial For Developers</a></bdi> <span class="bcsep">โข</span> <span class="curid"><bdi><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx" class="breadcrumbs" title="tutorialpocketsphinx">Building application with pocketsphinx</a></bdi></span></div>
</div>
<hr class="a11y">
</div></div><!-- /header -->
<div class="wrapper group">
<!-- ********** CONTENT ********** -->
<div id="dokuwiki__content"><div class="pad group">
<div class="pageId"><span>tutorialpocketsphinx</span></div>
<div class="page group">
<!-- wikipage start -->
<!-- TOC START -->
<div id="dw__toc">
<h3 style="cursor: pointer;" class="toggle open"><strong><span>โ</span></strong>Table of Contents</h3>
<div style="">
<ul style="" aria-expanded="true" class="toc">
<li class="level1"><div class="li"><a href="#building_application_with_pocketsphinx">Building application with pocketsphinx</a></div>
<ul class="toc">
<li class="level2"><div class="li"><a href="#installation">Installation</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#unix-like_installation">Unix-like Installation</a></div></li>
<li class="level3"><div class="li"><a href="#windows">Windows</a></div></li>
</ul>
</li>
<li class="level2"><div class="li"><a href="#pocketsphinx_api_core_ideas">Pocketsphinx API Core Ideas</a></div></li>
<li class="level2"><div class="li"><a href="#basic_usage_hello_world">Basic Usage (hello world)</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#initialization">Initialization</a></div></li>
<li class="level3"><div class="li"><a href="#decoding_a_file_stream">Decoding a file stream</a></div></li>
<li class="level3"><div class="li"><a href="#cleaning_up">Cleaning up</a></div></li>
<li class="level3"><div class="li"><a href="#code_listing">Code listing</a></div></li>
</ul>
</li>
<li class="level2"><div class="li"><a href="#advanced_usage">Advanced Usage</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#searches">Searches</a></div></li>
</ul></li>
</ul></li>
</ul>
</div>
</div>
<!-- TOC END -->
<h1 class="sectionedit1" id="building_application_with_pocketsphinx">Building application with pocketsphinx</h1>
<div class="level1">
</div>
<h2 class="sectionedit2" id="installation">Installation</h2>
<div class="level2">
<p>
Pocketsphinx is a library that depends on another library called
SphinxBase which provides common functionality
across all CMUSphinx projects. To install Pocketsphinx, you need to
install both Pocketsphinx and Sphinxbase. It's possible to use
Pocketsphinx both in Linux, Windows, on MacOS, iPhone and Android.
</p>
<p>
First of all, download the released packages pocketsphinx and sphinxbase
from project downloads, checkout them from subversion or github. For
more details see <a href="http://cmusphinx.sourceforge.net/wiki/download" class="wikilink1" title="download"> download page</a>.
</p>
<p>
Unpack them into same directory. On Windows, you will need to rename
'sphinxbase-X.Y' (where X.Y is the SphinxBase version number) to simply
'sphinxbase' to satisfy project pocketsphinx configuration.
</p>
<p>
<strong>THIS TUTORIAL DESCRIBES POCKETSPHINX 5PREALPHA, IT IS NOT GOING TO WORK ON OLDER VERSIONS
</strong>
</p>
</div>
<h3 class="sectionedit3" id="unix-like_installation">Unix-like Installation</h3>
<div class="level3">
<p>
To build pocketsphinx in a unix-like environment (such as Linux,
Solaris, FreeBSD etc) you need to make sure you have the following
dependencies installed: gcc, automake, autoconf, libtool, bison, swig at
least version 2.0, python development package, pulseaudio development
package. If you want to build without dependencies you can use proper
configure options like โwithout-swig-python but for beginner it is
recommended to install all dependencies.
</p>
<p>
You need to download both sphinxbase and pocketsphinx packages and
unpack them. Please note that you can not use sphinxbase and
pocketsphinx of different version, please make sure that versions are in
sync. After unpack you should see the following two main folders:
</p>
<pre class="code"> sphinxbase-X.X
pocketsphinx-X.x</pre>
<p>
On step one, build and install SphinxBase. Change current directory to <code>sphinxbase</code> folder. If you downloaded directly from the repository, you need to do this at least once to generate the <code>configure</code> file:
</p>
<pre class="code"> % ./autogen.sh</pre>
<p>
if you downloaded the release version, or ran <code>autogen.sh</code> at least once, then compile and install:
</p>
<pre class="code"> % ./configure
% make
% make install</pre>
<p>
The last step might require root permissions so it might be <code>sudo make install</code>.
If you want to use fixed-point arithmetic, you must configure
SphinxBase with the โenable-fixed option. You can also set installation
prefix with <code>โprefix</code>. You can also configure with or without SWIG python support.
</p>
<p>
The sphinxbase will be installed in <code>/usr/local/</code> folder by
default. Not every system loads libraries from this folder
automatically. To load them you need to configure the path to look for
shared libaries. It can be done either in the file <code>/etc/ld.so.conf</code> or with exporting environment variables:
</p>
<pre class="code"> export LD_LIBRARY_PATH=/usr/local/lib
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig</pre>
<p>
Then change to pocketsphinx folder and perform the same steps
</p>
<pre class="code"> % ./configure
% make
% make install</pre>
<p>
To test installation, run <code>'pocketsphinx_continuous -inmic yes</code>' and check that it recognizes words you are saying to the microphone.
</p>
</div>
<h3 class="sectionedit4" id="windows">Windows</h3>
<div class="level3">
<p>
In MS Windows (TM), under MS Visual Studio 2010 (or newer - we test with Visual C++ 2010 Express):
</p>
<ul>
<li class="level1"><div class="li"> load sphinxbase.sln located in sphinxbase directory</div>
</li>
<li class="level1"><div class="li"> compile all the projects in SphinxBase (from <code>sphinxbase.sln</code>)</div>
</li>
<li class="level1"><div class="li"> load <code>pocketsphinx.sln</code> in pocketsphinx directory</div>
</li>
<li class="level1"><div class="li"> compile all the projects in PocketSphinx</div>
</li>
</ul>
<p>
MS Visual Studio will build the executables and libraries under <code>.\bin\Release</code> or <code>.\bin\Debug</code> (depending on the target you choose on MS Visual Studio). To run <code>pocketsphinx_continuous.exe</code>,
don't forget to copy sphinxbase.dll to the bin folder. Otherwise the
executable will fail to find this library. Unlike on Linux, the path to
the model is not preconfigured in Windows, so you have to specify
pocketsphinx_continuous where to find the model with -hmm, -lm and -dict
options. Change to pocketsphinx folder and run
</p>
<pre class="code"> bin/Release/pocketsphinx_continuous.exe -inmic yes -hmm model/en-us/en-us -lm model/en-us/en-us.lm.bin -dict model/en-us/cmudict-en-us.dict</pre>
<p>
to recognize from microphone. To recognize from file run
</p>
<pre class="code"> bin/Release/pocketsphinx_continuous.exe -infile test/data/goforward.raw -hmm model/en-us/en-us -lm model/en-us/en-us.lm.bin -dict model/en-us/cmudict-en-us.dict</pre>
</div>
<h2 class="sectionedit5" id="pocketsphinx_api_core_ideas">Pocketsphinx API Core Ideas</h2>
<div class="level2">
<p>
Pocketsphinx <abbr title="Application Programming Interface">API</abbr> is designed to ease the use of speech recognizer functionality in your applications
</p>
<ol>
<li class="level1"><div class="li"> It is much more likely to remain stable both in terms of source and binary compatibility, due to the use of abstract types.</div>
</li>
<li class="level1"><div class="li"> It is fully re-entrant, so there is no problem having multiple decoders in the same process.</div>
</li>
<li class="level1"><div class="li"> It has enabled a drastic reduction in code footprint and a modest but significant reduction in memory consumption.</div>
</li>
</ol>
<p>
Reference documentation for the new <abbr title="Application Programming Interface">API</abbr> is available at <a href="http://cmusphinx.sourceforge.net/api/pocketsphinx/" class="urlextern" title="http://cmusphinx.sourceforge.net/api/pocketsphinx/" rel="nofollow">http://cmusphinx.sourceforge.net/api/pocketsphinx/</a>
</p>
</div>
<h2 class="sectionedit6" id="basic_usage_hello_world">Basic Usage (hello world)</h2>
<div class="level2">
<p>
There are few key things you need to know on how to use the <abbr title="Application Programming Interface">API</abbr>:
</p>
<ol>
<li class="level1"><div class="li"> Command-line parsing is done externally (in <code><cmd_ln.h></code>)</div>
</li>
<li class="level1"><div class="li"> Everything takes a <code>ps_decoder_t *</code> as the first argument.</div>
</li>
</ol>
<p>
To illustrate the new <abbr title="Application Programming Interface">API</abbr>,
we will step through a simple โhello worldโ example. This example is
somewhat specific to Unix in the locations of files and the compilation
process. We will create a C source file called <code>hello_ps.c</code>. To compile it (on Unix), use this command:
</p>
<pre class="code">gcc -o hello_ps hello_ps.c \
-DMODELDIR=\"`pkg-config --variable=modeldir pocketsphinx`\" \
`pkg-config --cflags --libs pocketsphinx sphinxbase`</pre>
<p>
Please note that compilation errors here mean that you didn't carefully
read the tutorial and didn't follow the installation guide above. For
example pocketsphinx needs to be properly installed to be available
through pkg-config system. To check that pocketsphinx is installed
properly, just run <code>pkg-config โcflags โlibs pocketsphinx sphinxbase</code> from the command line and see that output looks like
</p>
<pre class="code">-I/usr/local/include -I/usr/local/include/sphinxbase -I/usr/local/include/pocketsphinx
-L/usr/local/lib -lpocketsphinx -lsphinxbase -lsphinxad</pre>
</div>
<h3 class="sectionedit7" id="initialization">Initialization</h3>
<div class="level3">
<p>
The first thing we need to do is to create a configuration object, which for historical reasons is called <code>cmd_ln_t</code>. Along with the general boilerplate for our C program, we will do it like this:
</p>
<pre class="code">#include <pocketsphinx.h>
int
main(int argc, char *argv[])
{
ps_decoder_t *ps;
cmd_ln_t *config;
config = cmd_ln_init(NULL, ps_args(), TRUE,
"-hmm", MODELDIR "/en-us/en-us",
"-lm", MODELDIR "/en-us/en-us.lm.bin",
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
NULL);
if (config == NULL)
return 1;
return 0;
}</pre>
<p>
The <code>cmd_ln_init()</code> function takes a variable number of null-terminated string arguments, followed by NULL. The first argument is any previous <code>cmd_ln_t *</code> which is to be updated. The second argument is an array of argument definitions - the standard set can be obtained by calling <code>ps_args()</code>. The third argument is a flag telling the argument parser to be โstrictโ - if this is <code>TRUE</code>, then duplicate arguments or unknown arguments will cause parsing to fail.
</p>
<p>Note after compiling and executing the above code you will get no output, but you should see no errors either. If you get an error such as:
<b>
"error while loading shared libraries: libpocketsphinx.so.3"
</b>
You may want to run through the following steps:
<ol>
<li>Examine your <em>/etc/ld.so.conf</em> file. Usually it will either contain the list of directories that the linker looks for shared libraries in or it will pull in other
files from the /etc/ld.so.conf.d directory. Make sure that there is an entry that loads from the <em>/usr/local/lib</em> folder.</li>
<li>If you did the above and you still get this error. Then try running <em>sudo /sbin/ldconfig</em>. Sometimes the linker configuration needs to be refreshed especially if you have built and installed from source.
<p>
The <code>MODELDIR</code> macro is defined on the GCC command-line by using <code>pkg-config</code> to obtain the <code>modeldir</code> variable from PocketSphinx configuration. On Windows, you can simply add a preprocessor definition to the code, such as this:
</p>
<pre class="code">#define MODELDIR "c:/sphinx/model"</pre>
<p>
(replace this with wherever your models are installed). Now, to initialize the decoder, use ps_init:
</p>
<pre class="code"> ps = ps_init(config);
if (ps == NULL)
return 1;</pre>
</div>
<h3 class="sectionedit8" id="decoding_a_file_stream">Decoding a file stream</h3>
<div class="level3">
<p>
Because live audio input is somewhat platform-specific, we will confine
ourselves to decoding audio files. The โturtleโ language model
recognizes a very simple โrobot controlโ language, which recognizes
phrases such as โgo forward ten metersโ. In fact, there is an audio
file helpfully included in the PocketSphinx source code which contains
this very sentence. You can find it in <code>test/data/goforward.raw</code>.
Copy it to the current directory. If you want to create your own
version of it, it needs to be a single-channel (monaural),
little-endian, unheadered 16-bit signed PCM audio file sampled at 16000
Hz.
</p>
<p>
Main pocketsphinx use case is to read audio data in blocks of memory
from somewhere and feed them to the decoder. To do that we first open
the file and start decoding of the utterance using <code>ps_start_utt()</code>:
</p>
<pre class="code"> fseek(fh, 0, SEEK_SET);
rv = ps_start_utt(ps);
if (rv < 0)
return 1;</pre>
<p>
We will then read 512 samples at a time from the file, and feed them to the decoder using <code>ps_process_raw()</code>:
</p>
<pre class="code"> int16 buf[512];
while (!feof(fh)) {
size_t nsamp;
nsamp = fread(buf, 2, 512, fh);
rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
}</pre>
<p>
Then we will need to mark the end of the utterance using <code>ps_end_utt()</code>:
</p>
<pre class="code"> rv = ps_end_utt(ps);
if (rv < 0)
return 1;</pre>
<p>
Then we retrieve the hypothesis to get recognition result
</p>
<pre class="code"> hyp = ps_get_hyp(ps, &score);
if (hyp == NULL)
return 1;
printf("Recognized: %s\n", hyp);</pre>
</div>
<h3 class="sectionedit9" id="cleaning_up">Cleaning up</h3>
<div class="level3">
<p>
To clean up, simply call <code>ps_free()</code> on the object that was returned by <code>ps_init()</code>. Free the configuration object with cmd_ln_free_r.
</p>
</div>
<h3 class="sectionedit10" id="code_listing">Code listing</h3>
<div class="level3">
<pre class="code">#include <pocketsphinx.h>
int
main(int argc, char *argv[])
{
ps_decoder_t *ps;
cmd_ln_t *config;
FILE *fh;
char const *hyp, *uttid;
int16 buf[512];
int rv;
int32 score;
config = cmd_ln_init(NULL, ps_args(), TRUE,
"-hmm", MODELDIR "/en-us/en-us",
"-lm", MODELDIR "/en-us/en-us.lm.bin",
"-dict", MODELDIR "/en-us/cmudict-en-us.dict",
NULL);
if (config == NULL)
return 1;
ps = ps_init(config);
if (ps == NULL)
return 1;
fh = fopen("goforward.raw", "rb");
if (fh == NULL)
return -1;
rv = ps_start_utt(ps);
if (rv < 0)
return 1;
while (!feof(fh)) {
size_t nsamp;
nsamp = fread(buf, 2, 512, fh);
rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
}
rv = ps_end_utt(ps);
if (rv < 0)
return 1;
hyp = ps_get_hyp(ps, &score);
if (hyp == NULL)
return 1;
printf("Recognized: %s\n", hyp);
fclose(fh);
ps_free(ps);
cmd_ln_free_r(config);
return 0;
}
</pre>
</div>
<h2 class="sectionedit11" id="advanced_usage">Advanced Usage</h2>
<div class="level2">
<p>
For more complicated uses of the <abbr title="Application Programming Interface">API</abbr> please check the <abbr title="Application Programming Interface">API</abbr> reference.
</p>
<ol>
<li class="level1"><div class="li"> For word segmentations, the <abbr title="Application Programming Interface">API</abbr>
provides an iterator object which is used to, well, iterate over the
sequence of words. This iterator object is an abstract type, with some
accessors provided to obtain timepoints, scores, and (most
interestingly) posterior probabilities for each word.</div>
</li>
<li class="level1"><div class="li"> Confidence of the whole utterance can be accessed with ps_get_prob method.</div>
</li>
<li class="level1"><div class="li"> You can access lattice if needed</div>
</li>
<li class="level1"><div class="li"> You can configure multiple searches and switch between them in runtime.</div>
</li>
</ol>
</div>
<h3 class="sectionedit12" id="searches">Searches</h3>
<div class="level3">
<p>
Developer can configure several โsearchโ objects with different grammars
and langauge models and switch them in runtime to provide interactive
experience for the user.
</p>
<p>
There are different possible search modes:
</p>
<ol>
<li class="level1"><div class="li"> keyword - efficiently looks for keyphrase and ignores other speech. allows to configure detection threshold.</li></div>
</li>
<li class="level1"><div class="li"> grammar - recognizes speech
according to JSGF grammar. Unlike keyphrase grammar search doesn't
ignore words which are not in grammar but tries to recognize them.</div>
</li>
<li class="level1"><div class="li"> ngram/lm - recognizes natural speech with a language model.</div>
</li>
<li class="level1"><div class="li"> allphone - recognizes phonemes with a phonetic language model.</div>
</li>
</ol>
<p>
Each search has a name and can be referenced by a name, names are
application-specific. The function ps_set_search allows to activate the
search previously added by a name.
</p>
<p>
To add the search one needs to point to the grammar/language model
describing the search. The location of the grammar is specific to the
application. If only a simple recognition is required it is sufficient
to add a single search or just configure the required mode with
configuration options.
</p>
<p>
The exact design of a searches depends on your application. For example,
you might want to listen for activation keyword first and once keyword
is recognized switch to ngram search to recognize actual command. Once
you recognized the command you can switch to grammar search to recognize
the confirmation and then switch back to keyword listening mode to wait
for another command.
</p>
</div>
<!-- wikipage stop -->
</div>
<div class="docInfo"><bdi>tutorialpocketsphinx.txt</bdi> ยท Last modified: 2015/07/08 22:20 by <bdi>admin</bdi></div>
</div></div><!-- /content -->
<hr class="a11y">
<!-- PAGE ACTIONS -->
<div id="dokuwiki__pagetools">
<h3 class="a11y">Page Tools</h3>
<div class="tools">
<ul>
<li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=edit" class="action source" accesskey="v" rel="nofollow" title="Show pagesource [V]"><span>Show pagesource</span></a></li><li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=revisions" class="action revs" accesskey="o" rel="nofollow" title="Old revisions [O]"><span>Old revisions</span></a></li><li><a href="http://cmusphinx.sourceforge.net/wiki/tutorialpocketsphinx?do=backlink" class="action backlink" rel="nofollow" title="Backlinks"><span>Backlinks</span></a></li><li><a href="#dokuwiki__top" class="action top" accesskey="t" rel="nofollow" title="Back to top [T]"><span>Back to top</span></a></li> </ul>
</div>
</div>
</div><!-- /wrapper -->
<!-- ********** FOOTER ********** -->
<div id="dokuwiki__footer">
<div class="pad">
<div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <bdi><a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" rel="license" class="urlextern">CC Attribution-Noncommercial-Share Alike 3.0 Unported</a></bdi></div>
<div class="buttons">
<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/" rel="license"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/cc-by-nc-sa.png" alt="CC Attribution-Noncommercial-Share Alike 3.0 Unported"></a> <a href="http://www.dokuwiki.org/donate" title="Donate"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/button-donate.gif" alt="Donate" height="15" width="80"></a>
<a href="http://www.php.net/" title="Powered by PHP"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/button-php.gif" alt="Powered by PHP" height="15" width="80"></a>
<a href="http://validator.w3.org/check/referer" title="Valid HTML5"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/button-html5.png" alt="Valid HTML5" height="15" width="80"></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/button-css.png" alt="Valid CSS" height="15" width="80"></a>
<a href="http://dokuwiki.org/" title="Driven by DokuWiki"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/button-dw.png" alt="Driven by DokuWiki" height="15" width="80"></a>
</div>
</div>
</div><!-- /footer -->
</div></div><!-- /site -->
<div class="no"><img src="Building%20application%20with%20pocketsphinx%20%5BCMUSphinx%20Wiki%5D_files/indexer.gif" alt="" height="1" width="2"></div>
<div id="screen__mode" class="no"></div> <!--[if ( lte IE 7 | IE 8 ) ]></div><![endif]-->
</body></html>