Spaces:
Sleeping
Sleeping
| from flask import Flask, request, jsonify | |
| from flask_cors import CORS | |
| from text2generation import generate_long_answer | |
| from audio_scripter import generate_audio_script | |
| from image_scripter import generate_image_script | |
| from image_fetcher import fetch_images_from_prompts | |
| from video_creater import video_gen | |
| app = Flask(__name__) | |
| CORS(app) | |
| def health_check(): | |
| return jsonify({"status": "ready"}), 200 | |
| def ask_question(): | |
| try: | |
| global question | |
| data = request.get_json() | |
| question = data.get('question', '').strip() | |
| if not question: | |
| return jsonify({"error": "Question is required"}), 400 | |
| answer = generate_long_answer(question) | |
| audio_text = generate_audio_script(answer) | |
| lines = generate_image_script(question) | |
| image_prompts=lines.splitlines() | |
| fetch_images_from_prompts(image_prompts) | |
| video_gen(answer) | |
| return jsonify({ | |
| "question": question, | |
| "answer": answer | |
| }) | |
| except Exception as e: | |
| return jsonify({"error": str(e)}), 500 | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |