Class SpeechRecognitionHelper
- java.lang.Object
-
- ptolemy.actor.lib.jjs.HelperBase
-
- ptolemy.actor.lib.jjs.modules.speechRecognition.SpeechRecognitionHelper
-
public class SpeechRecognitionHelper extends HelperBase
A helper class for speech recognition. This class uses the CMU Sphinx-4 recognition engine. Note that speech synthesis (text-to-speech) is a separate capability not covered by Sphinx. https://github.com/cmusphinx/sphinx4 This helper only handles live speech at the moment. Sphinx also supports reading speech from a file. This could be added in the future. CapeCode uses CMU Sphinx4 for recognition. The library .jar files are around 35MB total, which is a bit large to check in to the repository. They need to be downloaded separately. Please place under $PTII/vendors/sphinx4 , then run ./configure. sphinx4-core-5prealpha.jar sphinx4-data-5prealpha.jarThen:
cd $PTII; ./configure
Sphinx works much better with a custom dictionary and language model. These can be generated from a file of sentences with an online tool. Please see: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=net.sf.phat&a=sphinx4-data&v=5prealpha&e=jar A sample dictionary, language model and sentence file from Sphinx4 are included with the demo: $PTII/ptolemy/actor/lib/jjs/modules/speechRecognition/demo/SpeechRecognition weather.dic, weather.lm and weather.samples- Since:
- Ptolemy II 11.0
- Version:
- $Id: SpeechRecognitionHelper.java 75909 2017-04-11 03:01:21Z beth@berkeley.edu $
- Author:
- Elizabeth Osyk
- Pt.AcceptedRating:
- Red (ltrnc)
- Pt.ProposedRating:
- Red (ltrnc)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.actor.lib.jjs.HelperBase
HelperBase.DATA_TYPE
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.lib.jjs.HelperBase
_actor, _currentObj
-
-
Constructor Summary
Constructors Constructor Description SpeechRecognitionHelper(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror helping, jdk.nashorn.api.scripting.ScriptObjectMirror options)
Construct a SpeechRecognitionHelper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setOptions(jdk.nashorn.api.scripting.ScriptObjectMirror options)
Set speech recognition options, including "continuous", "dictionaryPath", and "languageModelPath".void
start()
Start speech recognition.void
stop()
Stop speech recognition.-
Methods inherited from class ptolemy.actor.lib.jjs.HelperBase
_appendNumericToBuffer, _appendToBuffer, _error, _error, _error, _error, _extractFromBuffer, _issueResponse, _removeDuplicates, _sizeOfType, _toJavaBytes, _toJSArray, getHelping
-
-
-
-
Constructor Detail
-
SpeechRecognitionHelper
public SpeechRecognitionHelper(java.lang.Object actor, jdk.nashorn.api.scripting.ScriptObjectMirror helping, jdk.nashorn.api.scripting.ScriptObjectMirror options) throws IllegalActionException
Construct a SpeechRecognitionHelper.- Parameters:
actor
- The PtolemyII actor associated with this helper.helping
- The Javascript object this helper is helping.- Throws:
IllegalActionException
-
-
Method Detail
-
setOptions
public void setOptions(jdk.nashorn.api.scripting.ScriptObjectMirror options) throws IllegalActionException
Set speech recognition options, including "continuous", "dictionaryPath", and "languageModelPath".- Parameters:
options
- Speech recognition options, including "continuous", "dictionaryPath" and "languageModelPath".- Throws:
IllegalActionException
- If the language or dictionary files do not exist.
-
start
public void start() throws IllegalActionException
Start speech recognition. The recognizer runs in a separate thread, since it runs continuously.- Throws:
IllegalActionException
-
stop
public void stop()
Stop speech recognition.
-
-