RAPP Platform  v0.6.0
RAPP Platform is a collection of ROS nodes and back-end processes that aim to deliver ready-to-use generic services to robots
 All Classes Namespaces Files Functions Variables Macros
language_support.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 #Copyright 2015 RAPP
4 
5 #Licensed under the Apache License, Version 2.0 (the "License");
6 #you may not use this file except in compliance with the License.
7 #You may obtain a copy of the License at
8 
9  #http://www.apache.org/licenses/LICENSE-2.0
10 
11 #Unless required by applicable law or agreed to in writing, software
12 #distributed under the License is distributed on an "AS IS" BASIS,
13 #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #See the License for the specific language governing permissions and
15 #limitations under the License.
16 
17 # Authors: Athanassios Kintsakis, Aris Thallas, Manos Tsardoulias
18 # contact: akintsakis@issel.ee.auth.gr, aris.thallas@{iti.gr, gmail.com}, etsardou@iti.gr
19 
20 
21 import rospy
22 import sys
23 
24 from global_parameters import GlobalParams
25 from limited_vocabulary_creator import *
26 
27 from rapp_exceptions import RappError
28 from rapp_utilities import RappUtilities
29 
30 ## @class LanguageSupport
31 # @brief Allows the creation of configuration files for Sphinx speech recognition
32 class LanguageSupport(object):
33 
34  ## Performs initializations
35  def __init__(self):
36  ## Contains global Sphinx parameters
37  #
38  # (see global_parameters.GlobalParams)
39  self._globalParams = GlobalParams()
40 
41  ## The limited vocabulary creator
42  #
43  # Instantiates limited_vocabulary_creator.LimitedVocabularyCreator
45 
46  jar_path = ".:" + self._globalParams._sphinx_jar_files_url + "/" + \
47  self._globalParams._sphinx_jar_file + ":" + \
48  self._globalParams._sphinx_package_url + "/src"
49 
50  # Grammar is dummy here..
51  ## The generic Sphinx configuration
52  #
53  # @note Check acoustic model!!
55  'jar_path' : jar_path, \
56  'configuration_path' : self._globalParams._language_models_url + \
57  "/greekPack/default.config.xml", \
58  'acoustic_model' : self._globalParams._acoustic_models_url, \
59  'grammar_name' : 'hello', \
60  'grammar_folder' : self._globalParams._language_models_url + \
61  "/greekPack/", \
62  'dictionary' : self._globalParams._language_models_url + \
63  "/englishPack/cmudict-en-us.dict", \
64  'language_model' : self._globalParams._language_models_url + \
65  "/englishPack/en-us.lm.bin", \
66  'grammar_disabled' : True
67  }
68 
69 
70  ## Computes the Limited English Configuration
71  #
72  # @param words [list::string] The set of words to be identified
73  # @param grammar [list::string] The Sphinx grammar parameter
74  # @param sentences [list::string] The Sphinx sentences parameter
75  #
76  # @return limited_sphinx_configuration [dictionary] The Limited configuration
77  # @return englified_to_lang_dict [dictionary] A dictionary to transform the englified words to the words in the proper language
78  def getLimitedVocebularyConfiguration(self, words, grammar, sentences):
79  raise NotImplementedError("Child classes should explicitly override this function")
80 
81  ## Returns the Generic English Configuration
82  #
83  # @return #_generic_sphinx_configuration [dictionary] The Generic English configuration
Creates temporary configuration files for the input limited vocabulary.
def getGenericConfiguration
Returns the Generic English Configuration.
def getLimitedVocebularyConfiguration
Computes the Limited English Configuration.
Allows the creation of configuration files for Sphinx speech recognition.