Update app.py
Browse files
app.py
CHANGED
@@ -81,14 +81,15 @@ def extract_audio_from_video(video_path, output_audio_path):
|
|
81 |
except Exception as e:
|
82 |
raise Exception(f"Failed to extract audio from video: {str(e)}")
|
83 |
|
84 |
-
def send_fcm_data_message(fcm_token, transcription, file_type):
|
85 |
"""Send a silent FCM data message with transcription details"""
|
86 |
try:
|
87 |
message = messaging.Message(
|
88 |
data={
|
89 |
'transcription': transcription,
|
90 |
'file_type': file_type,
|
91 |
-
'
|
|
|
92 |
},
|
93 |
token=fcm_token
|
94 |
)
|
@@ -138,6 +139,8 @@ def transcribe():
|
|
138 |
|
139 |
file = request.files['file']
|
140 |
fcm_token = request.form['fcm_token']
|
|
|
|
|
141 |
if not (file and allowed_file(file.filename)):
|
142 |
return jsonify({'error': f'Invalid file format. Supported: {", ".join(ALLOWED_EXTENSIONS)}'}), 400
|
143 |
|
@@ -168,12 +171,10 @@ def transcribe():
|
|
168 |
file_type = 'video' if file_extension in ALLOWED_VIDEO_EXTENSIONS else 'audio'
|
169 |
|
170 |
# Send FCM data message
|
171 |
-
|
|
|
172 |
|
173 |
-
return jsonify({
|
174 |
-
'transcription': full_text,
|
175 |
-
'file_type': file_type
|
176 |
-
}), 200
|
177 |
|
178 |
except Exception as e:
|
179 |
return jsonify({'error': str(e)}), 500
|
|
|
81 |
except Exception as e:
|
82 |
raise Exception(f"Failed to extract audio from video: {str(e)}")
|
83 |
|
84 |
+
def send_fcm_data_message(fcm_token, transcription, file_type, created_date, transcription_name):
|
85 |
"""Send a silent FCM data message with transcription details"""
|
86 |
try:
|
87 |
message = messaging.Message(
|
88 |
data={
|
89 |
'transcription': transcription,
|
90 |
'file_type': file_type,
|
91 |
+
'created_date': created_date,
|
92 |
+
'transcription_name': transcription_name
|
93 |
},
|
94 |
token=fcm_token
|
95 |
)
|
|
|
139 |
|
140 |
file = request.files['file']
|
141 |
fcm_token = request.form['fcm_token']
|
142 |
+
created_date = request.form['created_date']
|
143 |
+
transcription_name = request.form['transcription_name']
|
144 |
if not (file and allowed_file(file.filename)):
|
145 |
return jsonify({'error': f'Invalid file format. Supported: {", ".join(ALLOWED_EXTENSIONS)}'}), 400
|
146 |
|
|
|
171 |
file_type = 'video' if file_extension in ALLOWED_VIDEO_EXTENSIONS else 'audio'
|
172 |
|
173 |
# Send FCM data message
|
174 |
+
# Send FCM data message
|
175 |
+
send_fcm_data_message(fcm_token, full_text, file_type, created_date, transcription_name)
|
176 |
|
177 |
+
return jsonify({}), 200
|
|
|
|
|
|
|
178 |
|
179 |
except Exception as e:
|
180 |
return jsonify({'error': str(e)}), 500
|