server: refactor with diarization, logic works

This commit is contained in:
2023-10-27 15:59:27 +02:00
committed by Mathieu Virbel
parent 1c42473da0
commit 07c4d080c2
17 changed files with 387 additions and 169 deletions

View File

@@ -62,6 +62,7 @@ class TranscriptTopic(BaseModel):
title: str
summary: str
timestamp: float
duration: float | None = 0
text: str | None = None
words: list[ProcessorWord] = []
@@ -264,7 +265,7 @@ class TranscriptController:
"""
A context manager for database transaction
"""
async with database.transaction():
async with database.transaction(isolation="serializable"):
yield
async def append_event(
@@ -280,5 +281,16 @@ class TranscriptController:
await self.update(transcript, {"events": transcript.events_dump()})
return resp
async def upsert_topic(
self,
transcript: Transcript,
topic: TranscriptTopic,
) -> TranscriptEvent:
"""
Append an event to a transcript
"""
transcript.upsert_topic(topic)
await self.update(transcript, {"topics": transcript.topics_dump()})
transcripts_controller = TranscriptController()