| from flask import Flask, request, send_file |
| import io |
| import os |
| import subprocess |
|
|
| app = Flask(__name__) |
|
|
| @app.route('/tts', methods=['POST']) |
| def synthesize(): |
| text = request.json.get('text', '') |
| output_path = '/tmp/output.mp3' |
| |
| subprocess.run([ |
| 'edge-tts', |
| '--voice', 'ru-RU-SvetlanaNeural', |
| '--text', text, |
| '--write-media', output_path |
| ], check=True) |
| |
| return send_file(output_path, mimetype='audio/mpeg') |
|
|
| @app.route('/') |
| def home(): |
| return 'Russian TTS OK' |
|
|
| if __name__ == '__main__': |
| app.run(host='0.0.0.0', port=7860) |