fix: resolve all QA/UAT report issues (P0-P3)
Made-with: Cursor
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -303,18 +303,49 @@ class EncoachPlacementController(http.Controller):
|
||||
@jwt_required
|
||||
def speaking_status(self, **kw):
|
||||
try:
|
||||
session_id = kw.get('session_id')
|
||||
upload_id = kw.get('upload_id')
|
||||
if not upload_id:
|
||||
return _error_response('upload_id is required', 400)
|
||||
|
||||
attachment = request.env['ir.attachment'].sudo().browse(int(upload_id))
|
||||
if not attachment.exists():
|
||||
return _error_response('Upload not found', 404)
|
||||
if session_id:
|
||||
session = request.env['encoach.cat.session'].sudo().browse(int(session_id))
|
||||
if not session.exists():
|
||||
return _error_response('Session not found', 404)
|
||||
|
||||
return _json_response({
|
||||
'status': 'completed',
|
||||
'transcription': None,
|
||||
})
|
||||
try:
|
||||
from odoo.addons.encoach_ai.services.whisper_service import WhisperService
|
||||
whisper = WhisperService(request.env)
|
||||
|
||||
attachments = request.env['ir.attachment'].sudo().search([
|
||||
('res_model', '=', 'encoach.cat.session'),
|
||||
('create_uid', '=', request.env.uid),
|
||||
], limit=1, order='create_date desc')
|
||||
|
||||
if attachments and attachments.datas:
|
||||
audio_data = base64.b64decode(attachments.datas)
|
||||
transcript = whisper.transcribe(audio_data, use_api=True)
|
||||
return _json_response({
|
||||
'status': 'scored',
|
||||
'transcription': transcript.get('text', ''),
|
||||
})
|
||||
except Exception as ai_err:
|
||||
_logger.warning('Whisper transcription not available: %s', ai_err)
|
||||
|
||||
return _json_response({
|
||||
'status': 'processing',
|
||||
'transcription': None,
|
||||
})
|
||||
|
||||
if upload_id:
|
||||
attachment = request.env['ir.attachment'].sudo().browse(int(upload_id))
|
||||
if not attachment.exists():
|
||||
return _error_response('Upload not found', 404)
|
||||
|
||||
return _json_response({
|
||||
'status': 'processing',
|
||||
'transcription': None,
|
||||
})
|
||||
|
||||
return _error_response('session_id or upload_id is required', 400)
|
||||
|
||||
except Exception as e:
|
||||
_logger.exception('speaking status failed')
|
||||
|
||||
Reference in New Issue
Block a user