Download app.py from akashdeb/ttstest: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/spaces/akashdeb/ttstest/resolve/main/app.py
- Command line
-
hf download hf://spaces/akashdeb/ttstest/app.py
-
curl -L -o app.py https://huggingface.co/spaces/akashdeb/ttstest/resolve/main/app.py
855 Bytes
| from flask import Flask, request, jsonify | |
| from flask_cors import CORS | |
| app = Flask(__name__) | |
| CORS(app) # Allows cross-origin requests | |
| def text_to_speech(): | |
| try: | |
| # Parse the JSON payload | |
| data = request.json | |
| if not data or 'text' not in data: | |
| return jsonify({"error": "Invalid input. 'text' is required."}), 400 | |
| text = data['text'] | |
| if not text.strip(): | |
| return jsonify({"error": "Text cannot be empty."}), 400 | |
| # Placeholder response (simulate TTS processing) | |
| response_message = f"Text received: '{text}'. Audio processing is simulated." | |
| return jsonify({"message": response_message}) | |
| except Exception as e: | |
| return jsonify({"error": str(e)}), 500 | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |