feat: add call history API endpoints and TTS service client
Adds read-only access to persisted call records for the dashboard and implements a client for the Rhema text-to-speech service. - api/call_history.py: New router providing paged call lists and detailed call records with transcript metadata. - services/tts.py: Async client for OpenAI-compatible TTS endpoints (Rhema/Kokoro) used for call-flow steps.
This commit is contained in:
@@ -138,6 +138,9 @@ class RecordingService:
|
||||
# Store metadata
|
||||
self._metadata.append(session.to_dict())
|
||||
|
||||
# Persist a recording row so the dashboard can find it later
|
||||
await self._persist_recording(session)
|
||||
|
||||
logger.info(
|
||||
f"⏹ Recording stopped: {call_id} "
|
||||
f"({session.duration_seconds}s, "
|
||||
@@ -145,6 +148,29 @@ class RecordingService:
|
||||
)
|
||||
return session
|
||||
|
||||
@staticmethod
|
||||
async def _persist_recording(session: "RecordingSession") -> None:
|
||||
"""Write a recordings row for this session. Failures are non-fatal."""
|
||||
try:
|
||||
import uuid as _uuid
|
||||
from db.database import RecordingRecord, get_session_factory
|
||||
|
||||
async with get_session_factory()() as db:
|
||||
db.add(RecordingRecord(
|
||||
id=f"rec_{_uuid.uuid4().hex[:10]}",
|
||||
call_id=session.call_id,
|
||||
path=session.filepath_mixed or "",
|
||||
format="wav",
|
||||
duration_s=float(session.duration_seconds or 0),
|
||||
size_bytes=int(session.file_size_bytes or 0),
|
||||
channels=1,
|
||||
started_at=session.started_at,
|
||||
ended_at=session.stopped_at,
|
||||
))
|
||||
await db.commit()
|
||||
except Exception as e:
|
||||
logger.warning(f"Recording persistence failed: {e}")
|
||||
|
||||
async def _recording_timeout(self, call_id: str) -> None:
|
||||
"""Auto-stop recording after max duration."""
|
||||
await asyncio.sleep(self._max_recording_seconds)
|
||||
|
||||
Reference in New Issue
Block a user