Пример #1
0
def recordEkhoTTS(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	filename = util.generateRandomName()+'.wav'
	subprocess.Popen(['ekho', '-v', language, '-t', 'wav', '-o', filename, text], stdin=PIPE, stdout=PIPE, stderr=STDOUT).communicate()
	
	md5fn = util.hashfileMD5(filename)+'.mp3'
	os.rename(filename_mp3, md5fn)
	
	return md5fn
Пример #2
0
	def recordsapi5TTS(text, voice):
		text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")))
		rndfn = util.generateRandomName()
		filename_wav = rndfn+'.wav'
		filename_mp3 = rndfn+'.mp3'
		subprocess.Popen([vbs_launcher, sapi5_path, '-hex', '-o', filename_wav, '-voice', util.dumpUnicodeStr(voice), util.dumpUnicodeStr(text)], startupinfo=util.si, stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		subprocess.Popen(['lame.exe', '--quiet', filename_wav, filename_mp3], startupinfo=util.si, stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		os.unlink(filename_wav)
		
		md5fn = util.hashfileMD5(filename_mp3)+'.mp3'
		os.rename(filename_mp3, md5fn)
		
		return md5fn
Пример #3
0
def recordEspeakTTS(text, language):
	text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
	filename = util.generateRandomName()+'.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()

	md5fn = util.hashfileMD5(filename)+'.mp3'
	os.rename(filename_mp3, md5fn)	

	return md5fn
Пример #4
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.generateRandomName()+'.mp3'
	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()
	else:
		subprocess.Popen(['mplayer', '-slave', '-user-agent', "'Mozilla/5.0'", address, '-dumpstream', '-dumpfile', file], stdin=PIPE, stdout=PIPE, stderr=STDOUT).wait()
		
	md5fn = util.hashfileMD5(file)+'.mp3'
	os.rename(file, md5fn)		
	
	return md5fn
Пример #5
0
	def recordOSXsayTTS(text, voice):
		text = re.sub("\[sound:.*?\]", "", stripHTML(text.replace("\n", "")).encode('utf-8'))
		
		rndfn = util.generateRandomName()
		filename_aiff = rndfn+'.aiff'
		filename_mp3 = rndfn+'.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()
		os.unlink(filename_aiff)

		md5fn = util.hashfileMD5(filename_mp3)+'.mp3'
		os.rename(filename_mp3, md5fn)
		
		return md5fn