30 lines
1016 B
Python
30 lines
1016 B
Python
|
|
"""Shared data models used across transcription engines."""
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
|
||
|
|
class TranscriptionResult:
|
||
|
|
"""Represents a transcription result."""
|
||
|
|
|
||
|
|
def __init__(self, text: str, is_final: bool, timestamp: datetime, user_name: str = ""):
|
||
|
|
"""
|
||
|
|
Initialize transcription result.
|
||
|
|
|
||
|
|
Args:
|
||
|
|
text: Transcribed text
|
||
|
|
is_final: Whether this is a final transcription or realtime preview
|
||
|
|
timestamp: Timestamp of transcription
|
||
|
|
user_name: Name of the user/speaker
|
||
|
|
"""
|
||
|
|
self.text = text.strip()
|
||
|
|
self.is_final = is_final
|
||
|
|
self.timestamp = timestamp
|
||
|
|
self.user_name = user_name
|
||
|
|
|
||
|
|
def __repr__(self) -> str:
|
||
|
|
time_str = self.timestamp.strftime("%H:%M:%S")
|
||
|
|
prefix = "[FINAL]" if self.is_final else "[PREVIEW]"
|
||
|
|
if self.user_name and self.user_name.strip():
|
||
|
|
return f"{prefix} [{time_str}] {self.user_name}: {self.text}"
|
||
|
|
return f"{prefix} [{time_str}] {self.text}"
|