Spaces:
Running
Running
some debuggings
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def process_video():
|
|
45 |
3. Return structured data in the response.
|
46 |
"""
|
47 |
if 'video' not in request.files:
|
48 |
-
return jsonify({"
|
49 |
|
50 |
video_file = request.files['video']
|
51 |
|
@@ -59,7 +59,7 @@ def process_video():
|
|
59 |
transcription = transcribe_audio(temp_video_file.name)
|
60 |
|
61 |
if not transcription:
|
62 |
-
return jsonify({"
|
63 |
|
64 |
# Generate structured recipe information using Gemini API
|
65 |
structured_data = query_gemini_api(transcription)
|
@@ -67,7 +67,7 @@ def process_video():
|
|
67 |
return jsonify(structured_data)
|
68 |
|
69 |
except Exception as e:
|
70 |
-
return jsonify({"
|
71 |
|
72 |
finally:
|
73 |
# Clean up temporary files
|
@@ -118,7 +118,7 @@ def transcribe_audio(video_path):
|
|
118 |
return result.get("text", "").strip()
|
119 |
|
120 |
except Exception as e:
|
121 |
-
print(f"Error in
|
122 |
return None
|
123 |
|
124 |
|
@@ -170,7 +170,7 @@ def query_gemini_api(transcription):
|
|
170 |
|
171 |
except requests.exceptions.RequestException as e:
|
172 |
print(f"Error querying Gemini API: {e}")
|
173 |
-
return {"
|
174 |
|
175 |
|
176 |
if __name__ == '__main__':
|
|
|
45 |
3. Return structured data in the response.
|
46 |
"""
|
47 |
if 'video' not in request.files:
|
48 |
+
return jsonify({"error1": "No video file provided"}), 400
|
49 |
|
50 |
video_file = request.files['video']
|
51 |
|
|
|
59 |
transcription = transcribe_audio(temp_video_file.name)
|
60 |
|
61 |
if not transcription:
|
62 |
+
return jsonify({"error2": "Audio transcription failed"}), 500
|
63 |
|
64 |
# Generate structured recipe information using Gemini API
|
65 |
structured_data = query_gemini_api(transcription)
|
|
|
67 |
return jsonify(structured_data)
|
68 |
|
69 |
except Exception as e:
|
70 |
+
return jsonify({"error3": str(e)}), 500
|
71 |
|
72 |
finally:
|
73 |
# Clean up temporary files
|
|
|
118 |
return result.get("text", "").strip()
|
119 |
|
120 |
except Exception as e:
|
121 |
+
print(f"Error in transcription4: {e}")
|
122 |
return None
|
123 |
|
124 |
|
|
|
170 |
|
171 |
except requests.exceptions.RequestException as e:
|
172 |
print(f"Error querying Gemini API: {e}")
|
173 |
+
return {"error5": str(e)}
|
174 |
|
175 |
|
176 |
if __name__ == '__main__':
|