Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
FlaskApp, TTS-mp3 (localhost:5000/Ich+bin+kein+Mensch)
from flask import Flask
from flask import send_file
from urllib.request import urlopen
import random, string
import os, glob
app = Flask(__name__)
def hello(tts):
for fl in glob.glob("*wav*"):
ttsnamef = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(6))
mp3file = urlopen("" % tts)
output = open('%s.wav' % ttsnamef,'wb')
os.system('lame -V 1 %s.wav %s.wav.mp3' % (ttsnamef, ttsnamef))
#os.remove("%s.wav" % ttsnamef)
return send_file("%s.wav.mp3" % ttsnamef, mimetype='audio/mp3')
if __name__ == "__main__":'', debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment