|
|
|
import os |
|
from flask import Flask, request, jsonify |
|
from flask_cors import CORS |
|
|
|
|
|
os.environ["XDG_CACHE_HOME"] = os.environ.get("XDG_CACHE_HOME", "/tmp/.cache") |
|
|
|
|
|
from whisper_server import handle_transcribe, model as whisper_model |
|
from qgen_server import handle_generate_questions, qg_model |
|
from qamatcher_server import handle_match_question, matcher_model |
|
|
|
app = Flask(__name__) |
|
|
|
|
|
CORS(app, resources={r"/*": {"origins": "*"}}) |
|
|
|
@app.route('/') |
|
def index(): |
|
return jsonify({ |
|
'message': 'VoiceQ AI Server is running!', |
|
'models_loaded': { |
|
'whisper': whisper_model is not None, |
|
'question-generator': qg_model is not None, |
|
'question-matcher': matcher_model is not None, |
|
} |
|
}) |
|
|
|
@app.route('/transcribe', methods=['POST']) |
|
def transcribe(): |
|
return handle_transcribe() |
|
|
|
@app.route('/generate-questions', methods=['POST']) |
|
def generate_questions(): |
|
return handle_generate_questions() |
|
|
|
@app.route('/match-question', methods=['POST']) |
|
def match_question(): |
|
return handle_match_question() |
|
|
|
|
|
if __name__ == '__main__': |
|
PORT = int(os.environ.get("PORT", 5001)) |
|
app.run(host='0.0.0.0', port=PORT, debug=True) |
|
|