コード例 #1
0
ファイル: speechtech.py プロジェクト: AoJ/alex
    def synthesize(self, text):
        """ Synthesize the text and returns it in a string with audio in default format and sample rate. """

        wav = b""
        
        try:
            if text:
                text = self.preprocessing.process(text)

                mp3 = self.get_tts_mp3(self.cfg['TTS']['SpeechTech']['voice'], text)
                wav = audio.convert_mp3_to_wav(self.cfg, mp3)
                wav = audio.change_tempo(self.cfg, self.cfg['TTS']['SpeechTech']['tempo'], wav)

#               if self.cfg['TTS']['debug']:
#                   m = "TTS cache hits %d and misses %d " % (self.get_tts_mp3.hits, self.get_tts_mp3.misses)
#                   self.cfg['Logging']['system_logger'].debug(m)
                return wav
            else:
                return b""
                
        except TTSException as e:
            m = unicode(e) + " Text: %s" % text
            self.cfg['Logging']['system_logger'].exception(m)
            return b""

        return wav
コード例 #2
0
ファイル: google.py プロジェクト: AoJ/alex
    def synthesize(self, text):
        """
        Synthesize the text and returns it in a string with audio in default
        format and sample rate.
        """
        wav = b""

        try:
            if text:
                text = self.preprocessing.process(text)

                mp3 = self.get_tts_mp3(self.cfg['TTS']['Google']['language'],
                                       text,
                                       self.cfg['TTS']['Google'].get('tempo', 1.0))
                wav = audio.convert_mp3_to_wav(self.cfg, mp3)
                wav = audio.change_tempo(self.cfg, self.cfg['TTS']['Google']['tempo'], wav)

                return wav
            else:
                return b""

        except TTSException as e:
            m = unicode(e) + " Text: %s" % text
            self.cfg['Logging']['system_logger'].exception(m)
            return b""

        return wav
コード例 #3
0
    def synthesize(self, text):
        """
        Synthesize the text and returns it in a string with audio in default
        format and sample rate.
        """
        try:
            if text:
                text = self.preprocessing.process(text)

                mp3 = self.get_tts_mp3(
                    self.cfg['TTS']['Google']['language'], text,
                    self.cfg['TTS']['Google'].get('tempo', 1.0))
                wav = audio.convert_mp3_to_wav(self.cfg, mp3)
                wav = audio.change_tempo(self.cfg,
                                         self.cfg['TTS']['Google']['tempo'],
                                         wav)

                return wav
            else:
                return b""

        except TTSException as e:
            m = unicode(e) + " Text: %s" % text
            self.cfg['Logging']['system_logger'].exception(m)
            return b""
コード例 #4
0
    def synthesize(self, text):
        """ Synthesize the text and returns it in a string with audio in default format and sample rate. """

        wav = b""

        try:
            if text:
                text = self.preprocessing.process(text)

                mp3 = self.get_tts_mp3(self.cfg['TTS']['SpeechTech']['voice'],
                                       text)
                wav = audio.convert_mp3_to_wav(self.cfg, mp3)
                wav = audio.change_tempo(
                    self.cfg, self.cfg['TTS']['SpeechTech']['tempo'], wav)

                #               if self.cfg['TTS']['debug']:
                #                   m = "TTS cache hits %d and misses %d " % (self.get_tts_mp3.hits, self.get_tts_mp3.misses)
                #                   self.cfg['Logging']['system_logger'].debug(m)
                return wav
            else:
                return b""

        except TTSException as e:
            m = unicode(e) + " Text: %s" % text
            self.cfg['Logging']['system_logger'].exception(m)
            return b""

        return wav