Update app.py
Browse files
app.py
CHANGED
@@ -82,22 +82,17 @@ tts_provider = ElevenlabsTTS()
|
|
82 |
@app.route('/', methods=['GET', 'POST'])
|
83 |
def index():
|
84 |
if request.method == 'POST':
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
preview_text = f"Hello, this is {voice}'s voice sample."
|
97 |
-
audio_file = tts_provider.tts(preview_text, voice)
|
98 |
-
return send_file(audio_file, mimetype='audio/mpeg', as_attachment=False)
|
99 |
-
except Exception as e:
|
100 |
-
return render_template('index.html', error=str(e), voices=tts_provider.all_voices.keys())
|
101 |
return render_template('index.html', voices=tts_provider.all_voices.keys())
|
102 |
|
103 |
if __name__ == "__main__":
|
|
|
82 |
@app.route('/', methods=['GET', 'POST'])
|
83 |
def index():
|
84 |
if request.method == 'POST':
|
85 |
+
text = request.form.get('text')
|
86 |
+
voice = request.form.get('voice', 'Brian')
|
87 |
+
try:
|
88 |
+
audio_file = tts_provider.tts(text, voice)
|
89 |
+
return render_template('index.html',
|
90 |
+
audio_file=audio_file,
|
91 |
+
voices=tts_provider.all_voices.keys(),
|
92 |
+
text=text,
|
93 |
+
voice=voice)
|
94 |
+
except Exception as e:
|
95 |
+
return render_template('index.html', error=str(e), voices=tts_provider.all_voices.keys())
|
|
|
|
|
|
|
|
|
|
|
96 |
return render_template('index.html', voices=tts_provider.all_voices.keys())
|
97 |
|
98 |
if __name__ == "__main__":
|