Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -49,10 +49,13 @@ def transcribe_in_background(audio_url, file_id, company, user):
|
|
49 |
# 2) Load with librosa
|
50 |
waveform, sr = librosa.load(audio_path, sr=16000)
|
51 |
|
52 |
-
# Optional: limit ~1 hour
|
53 |
max_sec = 3600
|
54 |
waveform = waveform[: sr * max_sec]
|
55 |
|
|
|
|
|
|
|
56 |
# 3) Split audio into 25-second chunks
|
57 |
chunk_sec = 25
|
58 |
chunk_size = sr * chunk_sec
|
@@ -72,9 +75,10 @@ def transcribe_in_background(audio_url, file_id, company, user):
|
|
72 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
73 |
partial_text += transcription + "\n"
|
74 |
|
75 |
-
# 4) Post final transcription back to Make.com, including
|
76 |
payload = {
|
77 |
"Transcription": partial_text.strip(),
|
|
|
78 |
"fileId": file_id,
|
79 |
"company": company,
|
80 |
"user": user
|
@@ -88,6 +92,7 @@ def transcribe_in_background(audio_url, file_id, company, user):
|
|
88 |
"fileId": file_id,
|
89 |
"company": company,
|
90 |
"user": user
|
|
|
91 |
}
|
92 |
requests.post(WEBHOOK_URL, json=error_payload)
|
93 |
|
|
|
49 |
# 2) Load with librosa
|
50 |
waveform, sr = librosa.load(audio_path, sr=16000)
|
51 |
|
52 |
+
# Optional: limit to ~1 hour
|
53 |
max_sec = 3600
|
54 |
waveform = waveform[: sr * max_sec]
|
55 |
|
56 |
+
# Calculate total duration actually analyzed
|
57 |
+
call_duration = int(len(waveform) / sr) # Rounded to nearest second
|
58 |
+
|
59 |
# 3) Split audio into 25-second chunks
|
60 |
chunk_sec = 25
|
61 |
chunk_size = sr * chunk_sec
|
|
|
75 |
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
76 |
partial_text += transcription + "\n"
|
77 |
|
78 |
+
# 4) Post final transcription back to Make.com, including extra fields
|
79 |
payload = {
|
80 |
"Transcription": partial_text.strip(),
|
81 |
+
"callDuration": call_duration,
|
82 |
"fileId": file_id,
|
83 |
"company": company,
|
84 |
"user": user
|
|
|
92 |
"fileId": file_id,
|
93 |
"company": company,
|
94 |
"user": user
|
95 |
+
# You could optionally include "callDuration" here if relevant
|
96 |
}
|
97 |
requests.post(WEBHOOK_URL, json=error_payload)
|
98 |
|