def __init__(self):
        ## Contains global Sphinx parameters
        #
        # (see global_parameters.GlobalParams)
        self._globalParams = GlobalParams()

        if not os.path.exists(self._globalParams._tmp_language_models_url):
            rospy.logwarn( "Language temporary directory does not exist. Path: " + \
                self._globalParams._tmp_language_models_url )
            os.makedirs(self._globalParams._tmp_language_models_url)

        ## The temporary directory containing the configurations
        self._languages_package = tempfile.mkdtemp( prefix='tmp_language_pack_', \
            dir = self._globalParams._tmp_language_models_url )

        # Delete temp file at termination
        atexit.register(shutil.rmtree, self._languages_package)

        ## The default configuration
        self._sphinx_configuration = { \
          'jar_path' : ".:" + self._globalParams._sphinx_jar_files_url + \
                "/" + self._globalParams._sphinx_jar_file + ":" \
                + self._globalParams._sphinx_package_url + "/src", \
          'configuration_path' : self._globalParams._language_models_url + \
                                          "/greekPack/default.config.xml", \
          'acoustic_model' : self._globalParams._acoustic_models_url, \
          'grammar_name' : '', \
          'grammar_folder' : '', \
          'dictionary' : '', \
          'language_model' : '', \
          'grammar_disabled' : True
          }
Exemple #2
0
    def __init__(self):
        ## Contains global Sphinx parameters
        #
        # (see global_parameters.GlobalParams)
        self._globalParams = GlobalParams()

        ## The limited vocabulary creator
        #
        # Instantiates limited_vocabulary_creator.LimitedVocabularyCreator
        self._vocabulary = LimitedVocabularyCreator()

        jar_path = ".:" + self._globalParams._sphinx_jar_files_url + "/" + \
            self._globalParams._sphinx_jar_file + ":" + \
            self._globalParams._sphinx_package_url + "/src"

        # Grammar is dummy here..
        ## The generic Sphinx configuration
        #
        # @note Check acoustic model!!
        self._generic_sphinx_configuration = { \
          'jar_path' : jar_path, \
          'configuration_path' : self._globalParams._language_models_url + \
                                          "/greekPack/default.config.xml", \
          'acoustic_model' : self._globalParams._acoustic_models_url, \
          'grammar_name' : 'hello', \
          'grammar_folder' : self._globalParams._language_models_url + \
                                                        "/greekPack/", \
          'dictionary' : self._globalParams._language_models_url + \
                                "/englishPack/cmudict-en-us.dict", \
          'language_model' : self._globalParams._language_models_url + \
                                          "/englishPack/en-us.lm.bin", \
          'grammar_disabled' : True
          }
    def __init__(self, configurationName=None):

        ## Contains global Sphinx parameters
        #
        # (see global_parameters.GlobalParams)
        self._globalParams = GlobalParams()

        ## The sphinx wrapper communicates with the actual Sphinx.java process
        #
        # (see sphinx4_wrapper.Sphinx4Wrapper)
        self._sphinx4 = Sphinx4Wrapper()
        ## Greek_support creates necessary files for Greek speech recognition
        #
        # (see greek_support.GreekSupport)
        self._greek_support = GreekEnglishSupport()
        ## English creates necessary files for english speech recognition
        #
        # (see english_support.EnglishSupport)
        self._english_support = EnglishSupport()
        ## The Sphinx configuration parameters
        #
        # (see sphinx4_configuration_params.SphinxConfigurationParams)
        self._configuration_params = SphinxConfigurationParams()

        ## A dictionary to transform the englified greek words to actual greek words
        self._word_mapping = {}

        if configurationName != None:
            self._createPreconfiguration(configurationName)
    def __init__(self, configuration=None):

        ## Contains global Sphinx parameters
        #
        # (see global_parameters.GlobalParams)
        self._globalParams = GlobalParams()

        ## The language of the request
        self._language = 'el'
        ## The words to be identified
        self._words = []
        ## Sphinx grammar attribute
        self._grammar = []
        ## Sphinx sentence attribute
        self._sentences = []

        if configuration != None:
            self._readConfigurationYaml(configuration)
    def __init__(self):
        ## Contains global Sphinx parameters
        #
        # (see global_parameters.GlobalParams)
        self._globalParams = GlobalParams()

        ## Sphinx configuration
        self._conf = ''
        ## Sphinx status flag
        self._sphinxDied = False

        ## The IPC socket
        self._sphinx_socket = None
        ## The IPC socket port
        self._sphinx_socket_PORT = None

        ## The Sphinx subprocess
        self._sphinxSubprocess = None

        # Denoise service topic name
        denoise_topic = rospy.get_param("rapp_audio_processing_denoise_topic")
        # Energy denoise service topic name
        energy_denoise_topic = \
            rospy.get_param("rapp_audio_processing_energy_denoise_topic")
        # Detect silence service topic name
        detect_silence_topic = \
            rospy.get_param("rapp_audio_processing_detect_silence_topic")
        # Transform audio service topic name
        audio_trans_topic = \
            rospy.get_param("rapp_audio_processing_transform_audio_topic")

        if (not denoise_topic):
            rospy.logerror("Audio processing denoise topic not found")
        if (not energy_denoise_topic):
            rospy.logerror("Audio processing energy denoise topic not found")
        if (not detect_silence_topic):
            rospy.logerror("Audio processing detect silence topic not found")
        if (not audio_trans_topic):
            rospy.logerror("Audio processing transform audio topic not found")

        ## @brief Denoise service client
        #
        # rapp_audio_processing.rapp_audio_processing.AudioProcessing::denoise
        self._denoise_service = rospy.ServiceProxy(\
                  denoise_topic, AudioProcessingDenoiseSrv)

        ## @brief Energy denoise service client
        #
        # rapp_audio_processing.rapp_audio_processing.AudioProcessing::energy_denoise
        self._energy_denoise_service = rospy.ServiceProxy(\
                  energy_denoise_topic, AudioProcessingDenoiseSrv)

        ## @brief Detect silence service client
        #
        # rapp_audio_processing.rapp_audio_processing.AudioProcessing::detect_silence
        self._detect_silence_service = rospy.ServiceProxy(\
                  detect_silence_topic, AudioProcessingDetectSilenceSrv)

        ## @brief Transform audio service client
        #
        # rapp_audio_processing.rapp_audio_processing.AudioProcessing::transform_audio
        self._audio_transform_srv = rospy.ServiceProxy( \
            audio_trans_topic, AudioProcessingTransformAudioSrv )

        ## Contains the absolute path for the Sphinx jar file
        self._jar_path = ".:" + self._globalParams._sphinx_jar_files_url + \
            "/" + self._globalParams._sphinx_jar_file + ":" \
                + self._globalParams._sphinx_package_url + "/src"

        self._initializeSphinxProcess()