Class 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.jar

    Then:

       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)
    • 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.
      • stop

        public void stop()
        Stop speech recognition.