File size: 717 Bytes
6727b6c 5e3251e 6727b6c 841ee9d 6727b6c 5e3251e 6727b6c 2c17bee 6727b6c 841ee9d 6727b6c 5e3251e 6727b6c 841ee9d 6727b6c 841ee9d 6727b6c | 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 27 28 29 30 31 | from flask import Flask, request, jsonify
from api import UrduWhisper
import uuid
import os
app = Flask(__name__)
model = UrduWhisper()
UPLOAD = "uploads"
os.makedirs(UPLOAD, exist_ok=True)
@app.route("/transcribe", methods=["POST"])
def transcribe_audio():
if "file" not in request.files:
return jsonify({"error": "No file uploaded"}), 400
file = request.files["file"]
filename = f"{UPLOAD}/{uuid.uuid4()}.wav"
file.save(filename)
text = model.transcribe(filename)
os.remove(filename)
return jsonify({"text": text})
@app.route("/")
def home():
return {"message": "Custom Urdu Whisper API Running!"}
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000) |