factory.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 
00003 
00004 # Import local libraries
00005 from rospeex_core import exceptions as ext
00006 from rospeex_core.ss.nict import Client as NICTClient
00007 from rospeex_core.ss.google import Client as GoogleClient
00008 from rospeex_core.ss.docomo_hoya import Client as docomo_hoyaClient
00009 from rospeex_core.ss.docomo_aitalk import Client as docomo_aitalkClient
00010 # from rospeex_core.ss.voicetext import Client as VoiceTextClient
00011 
00012 
00013 class SSEngine(object):
00014     """ engine enum class """
00015     NICT = 'nict'
00016     GOOGLE = 'google'
00017     # VOICETEXT = 'voicetext'
00018     DOCOMO_HOYA = 'docomo_hoya'
00019     DOCOMO_AITALK = 'docomo_aitalk'
00020 
00021 
00022 class SpeechSynthesisFactory(object):
00023     """ SpeechSynthesisFactory class """
00024     ENGINE_FACTORY = {
00025         'google': GoogleClient,
00026         'nict': NICTClient,
00027         # 'voicetext': VoiceTextClient,
00028         'docomo_hoya': docomo_hoyaClient,
00029         'docomo_aitalk': docomo_aitalkClient,
00030     }
00031 
00032     @classmethod
00033     def create(cls, engine=''):
00034         """
00035         create speech synthesis engine.
00036         @param engine: speech synthesis engine (nict / google / voicetext / docomo_hoya / docomo_aitalk)
00037         @type  engine: str
00038         @raise SpeechSynthesisException:
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. '\
00044                   'Except: {engine_list}'.format(
00045                         engine=engine,
00046                         engine_list=cls.ENGINE_FACTORY.keys()
00047                     )
00048             raise ext.SpeechSynthesisException(msg)


rospeex_core
Author(s): Komei Sugiura
autogenerated on Thu Apr 20 2017 03:08:53