Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -208,41 +208,31 @@ def process_audio():
|
|
208 |
|
209 |
audio_file = request.files['audio']
|
210 |
print("AUDIO FILE NAME: ", audio_file)
|
|
|
211 |
try:
|
212 |
-
print("
|
213 |
-
# Step 1:
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
transcription
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
print("GOT THE STRUCTURED DATA", structured_data)
|
234 |
-
# Step 4: Return the structured data
|
235 |
-
return jsonify(structured_data)
|
236 |
-
|
237 |
except Exception as e:
|
238 |
return jsonify({"error": str(e)}), 500
|
239 |
|
240 |
-
finally:
|
241 |
-
# Clean up temporary files
|
242 |
-
if os.path.exists(temp_audio_file.name):
|
243 |
-
os.remove(temp_audio_file.name)
|
244 |
-
|
245 |
-
|
246 |
def transcribe_audio(audio_path):
|
247 |
"""
|
248 |
Transcribe audio using Whisper AI.
|
|
|
208 |
|
209 |
audio_file = request.files['audio']
|
210 |
print("AUDIO FILE NAME: ", audio_file)
|
211 |
+
|
212 |
try:
|
213 |
+
print("STARTING TRANSCRIPTION, ANIKET")
|
214 |
+
# Step 1: Transcribe the uploaded audio file directly
|
215 |
+
audio_file = request.files['audio']
|
216 |
+
transcription = transcribe_audio(audio_file)
|
217 |
+
|
218 |
+
print("BEFORE THE transcription FAILED ERROR, CHECKING IF I GOT THE TRANSCRIPTION", transcription)
|
219 |
+
|
220 |
+
if not transcription:
|
221 |
+
return jsonify({"error": "Audio transcription failed"}), 500
|
222 |
+
|
223 |
+
print("GOT THE transcription")
|
224 |
+
|
225 |
+
print("Starting the GEMINI REQUEST TO STRUCTURE IT")
|
226 |
+
# Step 2: Generate structured recipe information using Gemini API
|
227 |
+
structured_data = query_gemini_api(transcription)
|
228 |
+
|
229 |
+
print("GOT THE STRUCTURED DATA", structured_data)
|
230 |
+
# Step 3: Return the structured data
|
231 |
+
return jsonify(structured_data)
|
232 |
+
|
|
|
|
|
|
|
|
|
|
|
233 |
except Exception as e:
|
234 |
return jsonify({"error": str(e)}), 500
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
def transcribe_audio(audio_path):
|
237 |
"""
|
238 |
Transcribe audio using Whisper AI.
|