Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions echo/server/dembrane/service/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,27 @@ def create_chunk(

conversation = self.get_by_id_or_raise(conversation_id)

# If the conversation was already finished+merged (e.g. auto-finished after
# a 5-min pause), reset its state so the finalization pipeline will run again
# once the user finishes recording. This ensures all segments are merged.
if conversation.get("is_finished") and conversation.get("merged_audio_path"):
logger.info(
f"Conversation {conversation_id} was already finished+merged. "
"Resetting state for new chunks."
)
with self._client_context() as client:
client.update_item(
"conversation",
conversation_id,
{
"is_finished": False,
"is_all_chunks_transcribed": False,
"merged_audio_path": None,
"duration": None,
"summary": None,
},
)

project = self.project_service.get_by_id_or_raise(conversation["project_id"])

if project.get("is_conversation_allowed", False) is False:
Expand Down
15 changes: 7 additions & 8 deletions echo/server/dembrane/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def task_transcribe_chunk(
)
return

transcribe_conversation_chunk(conversation_chunk_id, use_pii_redaction, anonymize_transcripts)
transcribe_conversation_chunk(
conversation_chunk_id, use_pii_redaction, anonymize_transcripts
)

# Transcription succeeded - decrement counter and check for finalization
_on_chunk_transcription_done(conversation_id, conversation_chunk_id, logger)
Expand Down Expand Up @@ -575,12 +577,7 @@ def task_merge_conversation_chunks(conversation_id: str) -> None:

try:
try:
conversation = conversation_service.get_by_id_or_raise(conversation_id)

if conversation["is_finished"] and conversation["merged_audio_path"] is not None:
logger.info(f"Conversation {conversation_id} already merged, skipping")
return

conversation_service.get_by_id_or_raise(conversation_id)
except Exception:
logger.error(f"Conversation not found: {conversation_id}")
return
Expand Down Expand Up @@ -777,7 +774,9 @@ def task_process_conversation_chunk(

group(
[
task_transcribe_chunk.message(cid, conversation_id, use_pii_redaction, anonymize_transcripts)
task_transcribe_chunk.message(
cid, conversation_id, use_pii_redaction, anonymize_transcripts
)
for cid in valid_chunk_ids
]
).run()
Expand Down
Loading