|
import os |
|
os.system("pip install --upgrade pip") |
|
os.system("pip install TTS --no-deps --upgrade-strategy only-if-needed --exists-action i") |
|
from flask import Flask, request, send_file, render_template |
|
from TTS.api import TTS |
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
tts = TTS(model_name="tts_models/ja/kokoro/tacotron2-DDC", progress_bar=False, gpu=False) |
|
|
|
|
|
@app.route('/') |
|
def home(): |
|
return render_template('index.html') |
|
|
|
|
|
@app.route('/generate_audio', methods=['POST']) |
|
def generate_audio(): |
|
text = request.form['text'] |
|
audio_path = "static/output.wav" |
|
tts.tts_to_file(text=text, file_path=audio_path) |
|
|
|
return send_file(audio_path, as_attachment=True) |
|
|
|
if __name__ == '__main__': |
|
app.run(debug=True) |
|
|