def _say(self, phrase, language, voice, voiceinfo, options): cmd = [ 'say', phrase ] self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd)
def _say(self, phrase, language, voice, voiceinfo, options): with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f: fname = f.name cmd = ['pico2wave', '-l', voice, '-w', fname, phrase] self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd) self.play(fname) os.remove(fname)
def _say(self, phrase, language, voice, voiceinfo, options): cmd = ['festival', '--pipe'] with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f: fname = f.name with tempfile.SpooledTemporaryFile() as in_f: in_f.write(self.SAY_TEMPLATE.format(outfilename=fname, phrase=phrase.replace('\\', '\\\\"').replace('"', '\\"')).encode('utf-8')) in_f.seek(0) self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd, stdin=in_f) self.play(fname) os.remove(fname)
def _get_languages(self): cmd = ['pico2wave', '-l', 'NULL', '-w', os.devnull] with tempfile.SpooledTemporaryFile() as f: subprocess.call(cmd, stderr=f) f.seek(0) output = f.read().decode('utf-8') pattern = re.compile(r'Unknown language: NULL\nValid languages:\n((?:[a-z]{2}-[A-Z]{2}\n)+)') matchobj = pattern.match(output) voices = matchobj.group(1).split() langs = {} for voice in voices: lang = voice[:2] langs.setdefault(lang, {'default': voice, 'voices': {}}) langs[lang]['voices'][voice] = {} return langs
def _say(self, phrase, language, voice, voiceinfo, options): cmd = ['festival', '--pipe'] with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f: fname = f.name with tempfile.SpooledTemporaryFile() as in_f: in_f.write( self.SAY_TEMPLATE.format(outfilename=fname, phrase=phrase.replace( '\\', '\\\\"').replace( '"', '\\"')).encode('utf-8')) in_f.seek(0) self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd, stdin=in_f) self.play(fname) os.remove(fname)
def _say(self, phrase, language, voice, voiceinfo, options): with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f: fname = f.name vce = voice if voiceinfo['type'] == 'espeak' and options['variant']: vce += '+' + options['variant'] cmd = [ self.ioptions['espeak'], '-v', vce, '-p', options['pitch_adjustment'], '-s', options['words_per_minute'], '-w', fname, phrase ] cmd = [str(x) for x in cmd] self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd) self.play(fname) os.remove(fname)
def _get_languages(self): cmd = ['pico2wave', '-l', 'NULL', '-w', os.devnull] with tempfile.SpooledTemporaryFile() as f: subprocess.call(cmd, stderr=f) f.seek(0) output = f.read().decode('utf-8') pattern = re.compile( r'Unknown language: NULL\nValid languages:\n((?:[a-z]{2}-[A-Z]{2}\n)+)' ) matchobj = pattern.match(output) voices = matchobj.group(1).split() langs = {} for voice in voices: lang = voice[:2] langs.setdefault(lang, {'default': voice, 'voices': {}}) langs[lang]['voices'][voice] = {} return langs
def _say(self, phrase, language, voice, voiceinfo, options): cmd = ['say', phrase] self._logger.debug('Executing %s', ' '.join([pipes.quote(arg) for arg in cmd])) subprocess.call(cmd)