diff --git a/drb-c2-core/app/internal/mqtt_handler.py b/drb-c2-core/app/internal/mqtt_handler.py index 229df34..601ee55 100644 --- a/drb-c2-core/app/internal/mqtt_handler.py +++ b/drb-c2-core/app/internal/mqtt_handler.py @@ -193,7 +193,7 @@ class MQTTHandler: if payload.get("audio_url"): updates["audio_url"] = payload["audio_url"] - await fstore.doc_update("calls", call_id, updates) + await fstore.doc_set("calls", call_id, updates) logger.info(f"Call end: {call_id}") # ------------------------------------------------------------------ diff --git a/drb-c2-core/app/internal/transcription.py b/drb-c2-core/app/internal/transcription.py index 7a898a5..c05600c 100644 --- a/drb-c2-core/app/internal/transcription.py +++ b/drb-c2-core/app/internal/transcription.py @@ -35,7 +35,7 @@ async def transcribe_call(call_id: str, gcs_uri: str) -> Optional[str]: if transcript: try: - await fstore.doc_update("calls", call_id, {"transcript": transcript}) + await fstore.doc_set("calls", call_id, {"transcript": transcript}) logger.info(f"Transcript saved for call {call_id} ({len(transcript)} chars)") except Exception as e: logger.warning(f"Could not save transcript for {call_id}: {e}") @@ -46,8 +46,17 @@ async def transcribe_call(call_id: str, gcs_uri: str) -> Optional[str]: def _sync_transcribe(gcs_uri: str) -> Optional[str]: """Synchronous STT call — run in a thread via asyncio.to_thread.""" from google.cloud import speech + from app.config import settings - client = speech.SpeechClient() + if settings.gcp_credentials_path: + from google.oauth2 import service_account + creds = service_account.Credentials.from_service_account_file( + settings.gcp_credentials_path, + scopes=["https://www.googleapis.com/auth/cloud-platform"], + ) + client = speech.SpeechClient(credentials=creds) + else: + client = speech.SpeechClient() audio = speech.RecognitionAudio(uri=gcs_uri) config = speech.RecognitionConfig( diff --git a/drb-c2-core/app/routers/upload.py b/drb-c2-core/app/routers/upload.py index 7f3905b..008912e 100644 --- a/drb-c2-core/app/routers/upload.py +++ b/drb-c2-core/app/routers/upload.py @@ -49,7 +49,7 @@ async def upload_call_audio( if audio_url: try: - await fstore.doc_update("calls", call_id, {"audio_url": audio_url}) + await fstore.doc_set("calls", call_id, {"audio_url": audio_url}) except Exception as e: logger.warning(f"Could not update call {call_id} with audio_url: {e}")