Download app.py from sreepathi-ravikumar/backendprocesstts: direct link, hf CLI and curl.
- Browser
- Download file 545 Bytes
-
https://huggingface.co/spaces/sreepathi-ravikumar/backendprocesstts/resolve/main/app.py
- Command line
-
hf download hf://spaces/sreepathi-ravikumar/backendprocesstts/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sreepathi-ravikumar/backendprocesstts/resolve/main/app.py
545 Bytes
| from flask import Flask, request, send_file | |
| from flask_cors import CORS | |
| import edge_tts | |
| import asyncio | |
| import uuid | |
| app = Flask(__name__) | |
| CORS(app) | |
| def tts(): | |
| text = request.json.get('text', '').strip() | |
| if not text: | |
| return {'error': 'No text'}, 400 | |
| filename = f"{uuid.uuid4()}.mp3" | |
| asyncio.run(edge_tts.Communicate(text, 'en-US-JennyNeural').save(filename)) | |
| return send_file(filename, mimetype='audio/mpeg') | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) |