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