transcription_api.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    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