Spaces:
Runtime error
Runtime error
Download app.py from eagien/Index-TTS-Deploy: direct link, hf CLI and curl.
- Browser
- Download file 667 Bytes
-
https://huggingface.co/spaces/eagien/Index-TTS-Deploy/resolve/main/app.py
- Command line
-
hf download hf://spaces/eagien/Index-TTS-Deploy/app.py
-
curl -L -o app.py https://huggingface.co/spaces/eagien/Index-TTS-Deploy/resolve/main/app.py
667 Bytes
| import os | |
| os.environ["HF_HOME"] = "/tmp/huggingface" | |
| os.environ["TRANSFORMERS_CACHE"] = "/tmp/huggingface/transformers" | |
| from transformers import pipeline | |
| from flask import Flask, request, jsonify | |
| # 加载 TTS 模型 | |
| tts = pipeline("text-to-speech", model="suno/bark") | |
| # 创建 Flask 应用 | |
| app = Flask(__name__) | |
| def speak(): | |
| text = request.json.get("text", "") | |
| if not text: | |
| return jsonify({"error": "No text provided"}), 400 | |
| output = tts(text) | |
| return jsonify(output) | |
| def index(): | |
| return "TTS pipeline is ready!" | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) | |