self.sql = SQL() if not self.sql else self.sql
if response.status_code == 200:
result = response.json()
transcription = result['text']
# Store the transcription in PostgreSQL
self.sql.execute(
"INSERT INTO transcriptions (file_id, transcription) \
VALUES (%s, %s)",
(file_id, transcription)
)
return {
"message": "Transcription completed and stored",
"file_id": file_id
}, 200
else:
return {
"error": "Transcription failed",
"details": response.text
}, 500