Go to the documentation of this file.00001
00002
00003
00004 import logging
00005
00006
00007 from rospeex_core.exceptions import SpeechRecognitionException
00008 from rospeex_core.sr.client_nict import SpeechRecognitionClient_NICT
00009 from rospeex_core.sr.client_google import SpeechRecognitionClient_Google
00010
00011
00012
00013 logging.basicConfig(level=logging.INFO)
00014 logger = logging.getLogger(__name__)
00015
00016
00017 class SREngine(object):
00018 """ Engine class """
00019 NICT = 'nict'
00020 GOOGLE = 'google'
00021
00022
00023 class SpeechRecognitionFactory(object):
00024 """
00025 SpeechRecognitionFactory class
00026 """
00027 ENGINE_FACTORY = {
00028 'google': SpeechRecognitionClient_Google,
00029 'nict': SpeechRecognitionClient_NICT,
00030 }
00031
00032 @classmethod
00033 def create(cls, engine):
00034 """
00035 create speech recognition client
00036 @param engine: speech recognition engine name (NICT|GOOGLE)
00037 @type engine: str
00038 @raise SpeechRecognitionException:
00039 """
00040 if engine in cls.ENGINE_FACTORY.keys():
00041 return cls.ENGINE_FACTORY[engine]()
00042 else:
00043 msg = 'target client [{engine}] is not found. Except: {engine_list}'.format(
00044 engine=engine,
00045 engine_list=cls.ENGINE_FACTORY.keys()
00046 )
00047 raise SpeechRecognitionException(msg)