Exemplo n.º 1
0
	def recordOSXsayTTS(text, voice):
		text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
		filename_aiff = util.generateFileName(text, 'say', 'iso-8859-1', '.aiff')
		filename_mp3 = util.generateFileName(text, 'say', 'iso-8859-1', '.mp3')
		subprocess.Popen(['say', '-v', voice, '-o', filename_aiff, text], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		subprocess.Popen(['lame', '--quiet', filename_aiff, filename_mp3], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		subprocess.Popen(['rm', filename_aiff], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		return filename_mp3.decode('utf-8')
Exemplo n.º 2
0
def TTS_record_old(text, language):
    text = re.sub("\[sound:.*?\]", "",
                  stripHTML(text.replace("\n", "")).encode('utf-8'))
    address = TTS_ADDRESS + '?tl=' + language + '&q=' + quote_plus(text)

    file = util.generateFileName(text, 'g',
                                 slanguages[get_language_id(language)][2])
    if subprocess.mswindows:
        subprocess.Popen([
            'mplayer.exe', '-ao', 'win32', '-slave', '-user-agent',
            "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file
        ],
                         startupinfo=util.si,
                         stdin=PIPE,
                         stdout=PIPE,
                         stderr=STDOUT).wait()
        if not config.quote_mp3:
            return file.decode(slanguages[get_language_id(language)][2])
    else:
        subprocess.Popen([
            'mplayer', '-slave', '-user-agent', "'Mozilla/5.0'", address,
            '-dumpstream', '-dumpfile', file
        ],
                         stdin=PIPE,
                         stdout=PIPE,
                         stderr=STDOUT).wait()
    return file.decode('utf-8')
Exemplo n.º 3
0
 def recordOSXsayTTS(text, voice):
     text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode("utf-8"))
     hasher = hashlib.md5()
     hasher.update(text)
     hasher.update(time.asctime())  # trying to avoid overwriting files with the same text in different decks
     filename_aiff = util.generateFileName(hasher.hexdigest(), "say", "iso-8859-1", ".aiff")
     filename_mp3 = util.generateFileName(hasher.hexdigest(), "say", "iso-8859-1", ".mp3")
     subprocess.Popen(["say", "-v", voice, "-o", filename_aiff, text], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
     encoder_args = ["lame"]  # encoder executable
     encoder_args.append("--quiet")  # suppressing console output
     encoder_args.extend(["--abr", "28", "-q0"])  # quality related settings
     encoder_args.extend(
         ["--id3v2-only", "--tt", text]
     )  # writing text to ID tag to be able to quick find proper file in a library
     encoder_args.extend([filename_aiff, filename_mp3])
     subprocess.Popen(encoder_args, stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
     subprocess.Popen(["rm", filename_aiff], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
     return filename_mp3.decode("utf-8")
Exemplo n.º 4
0
def recordEkhoTTS(text, language):
    text = re.sub("\[sound:.*?\]", "",
                  stripHTML(text.replace("\n", "")).encode('utf-8'))
    filename = util.generateFileName(text, 'ekho', 'iso-8859-1', '.wav')
    subprocess.Popen(
        ['ekho', '-v', language, '-t', 'wav', '-o', filename, text],
        stdin=PIPE,
        stdout=PIPE,
        stderr=STDOUT).communicate()
    return filename.decode('utf-8')
Exemplo n.º 5
0
 def recordOSXsayTTS(text, voice):
     text = re.sub("\[sound:.*?\]", "",
                   stripHTML(text.replace("\n", "")).encode('utf-8'))
     filename_aiff = util.generateFileName(text, 'say', 'iso-8859-1',
                                           '.aiff')
     filename_mp3 = util.generateFileName(text, 'say', 'iso-8859-1', '.mp3')
     subprocess.Popen(['say', '-v', voice, '-o', filename_aiff, text],
                      stdin=PIPE,
                      stdout=PIPE,
                      stderr=STDOUT).wait()
     subprocess.Popen(['lame', '--quiet', filename_aiff, filename_mp3],
                      stdin=PIPE,
                      stdout=PIPE,
                      stderr=STDOUT).wait()
     subprocess.Popen(['rm', filename_aiff],
                      stdin=PIPE,
                      stdout=PIPE,
                      stderr=STDOUT).wait()
     return filename_mp3.decode('utf-8')
Exemplo n.º 6
0
def recordEspeakTTS(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	filename = util.generateFileName(text, 'espeak', 'iso-8859-1', '.mp3')
	espeak_exec = subprocess.Popen(['espeak', '-v', language, text, '--stdout'], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
	lame_exec = Popen(["lame", "-", filename], stdin=espeak_exec.stdout, stdout = PIPE)
	espeak_exec.stdout.close()
	result = lame_exec.communicate()[0]
	espeak_exec.wait()

	return filename.decode('utf-8')
Exemplo n.º 7
0
def TTS_record_old(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	address = TTS_ADDRESS+'?tl='+language+'&q='+ quote_plus(text)
	
	file = util.generateFileName(text, 'g', slanguages[get_language_id(language)][2])
	if subprocess.mswindows:
		subprocess.Popen(['mplayer.exe', '-ao', 'win32', '-slave', '-user-agent', "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file], startupinfo=util.si, stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		if not config.quote_mp3:
			return file.decode(slanguages[get_language_id(language)][2])
	else:
		subprocess.Popen(['mplayer', '-slave', '-user-agent', "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
	return file.decode('utf-8')
Exemplo n.º 8
0
def _recordAcapela(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	address = TTS_ADDRESS+'?' + urllib.urlencode(prepareAcapela(text, language))
	
	file = util.generateFileName(text, 'acap', 'utf-8')
	if subprocess.mswindows:
		subprocess.Popen(['mplayer.exe', '-ao', 'win32', '-slave', '-user-agent', "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file], startupinfo=util.si, stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		if not config.quote_mp3:
			return file.decode('utf-8')
	else:
		subprocess.Popen(['mplayer', '-slave', '-user-agent', "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
	return file.decode('utf-8')
Exemplo n.º 9
0
def recordEspeakTTS(text, language):
    text = re.sub("\[sound:.*?\]", "",
                  stripHTML(text.replace("\n", "")).encode('utf-8'))
    filename = util.generateFileName(text, 'espeak', 'iso-8859-1', '.mp3')
    espeak_exec = subprocess.Popen(
        ['espeak', '-v', language, text, '--stdout'],
        stdin=PIPE,
        stdout=PIPE,
        stderr=STDOUT)
    lame_exec = Popen(["lame", "-", filename],
                      stdin=espeak_exec.stdout,
                      stdout=PIPE)
    espeak_exec.stdout.close()
    result = lame_exec.communicate()[0]
    espeak_exec.wait()

    return filename.decode('utf-8')
Exemplo n.º 10
0
def recordEkhoTTS(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	filename = util.generateFileName(text, 'ekho', 'iso-8859-1', '.wav')
	subprocess.Popen(['ekho', '-v', language, '-t', 'wav', '-o', filename, text], stdin=PIPE, stdout=PIPE, stderr=STDOUT).communicate()
	return filename.decode('utf-8')