Issue Fix

Upload 404 warning	doc_set(merge=True) in upload.py — creates doc if missing
MQTT call_end 404 error	doc_set(merge=True) in mqtt_handler.py — same root cause
Transcription 404 (saving transcript to nonexistent doc)	doc_set(merge=True) in transcription.py
Transcription ADC credentials error	Explicit service_account.Credentials from gcp-key.json in _sync_transcribe — same pattern as storage.py
This commit is contained in:
Logan
2026-04-12 22:04:11 -04:00
parent 66316efa53
commit 357553f1ea
3 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ class MQTTHandler:
if payload.get("audio_url"): if payload.get("audio_url"):
updates["audio_url"] = payload["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}") logger.info(f"Call end: {call_id}")
# ------------------------------------------------------------------ # ------------------------------------------------------------------
+10 -1
View File
@@ -35,7 +35,7 @@ async def transcribe_call(call_id: str, gcs_uri: str) -> Optional[str]:
if transcript: if transcript:
try: 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)") logger.info(f"Transcript saved for call {call_id} ({len(transcript)} chars)")
except Exception as e: except Exception as e:
logger.warning(f"Could not save transcript for {call_id}: {e}") logger.warning(f"Could not save transcript for {call_id}: {e}")
@@ -46,7 +46,16 @@ async def transcribe_call(call_id: str, gcs_uri: str) -> Optional[str]:
def _sync_transcribe(gcs_uri: str) -> Optional[str]: def _sync_transcribe(gcs_uri: str) -> Optional[str]:
"""Synchronous STT call — run in a thread via asyncio.to_thread.""" """Synchronous STT call — run in a thread via asyncio.to_thread."""
from google.cloud import speech from google.cloud import speech
from app.config import settings
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() client = speech.SpeechClient()
audio = speech.RecognitionAudio(uri=gcs_uri) audio = speech.RecognitionAudio(uri=gcs_uri)
+1 -1
View File
@@ -49,7 +49,7 @@ async def upload_call_audio(
if audio_url: if audio_url:
try: 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: except Exception as e:
logger.warning(f"Could not update call {call_id} with audio_url: {e}") logger.warning(f"Could not update call {call_id} with audio_url: {e}")