Spaces:
Running
Running
File size: 486 Bytes
2d59b32 ac8fb27 cb6aeb9 2d59b32 cb6aeb9 ac8fb27 cb6aeb9 1f09361 cb6aeb9 ac8fb27 cb6aeb9 ac8fb27 cb6aeb9 1f09361 cb6aeb9 1f09361 cb6aeb9 2d59b32 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from flask import Flask, request, send_file
from gtts import gTTS
import os
app = Flask(__name__)
@app.route("/")
def home():
return "TTS API Running"
@app.route("/tts", methods=["POST"])
def tts():
text = request.json.get("text")
if not text:
return "No text", 400
file = "out.mp3"
tts = gTTS(text=text, lang='hi')
tts.save(file)
return send_file(file, mimetype="audio/mpeg")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860) |