processors(rtvi): use only user-transcription

This commit is contained in:
Aleix Conchillo Flaqué
2024-07-22 09:40:16 -07:00
parent cea4d1894e
commit 43932220f7

View File

@@ -131,6 +131,7 @@ class RTVITranscriptionMessageData(BaseModel):
text: str
user_id: str
timestamp: str
final: bool
class RTVITranscriptionMessage(BaseModel):
@@ -139,12 +140,6 @@ class RTVITranscriptionMessage(BaseModel):
data: RTVITranscriptionMessageData
class RTVIInterimTranscriptionMessage(BaseModel):
label: Literal["rtvi"] = "rtvi"
type: Literal["user-interim-transcription"] = "user-interim-transcription"
data: RTVITranscriptionMessageData
class RTVIUserStartedSpeakingMessage(BaseModel):
label: Literal["rtvi"] = "rtvi"
type: Literal["user-started-speaking"] = "user-started-speaking"
@@ -318,11 +313,15 @@ class RTVIProcessor(FrameProcessor):
data=RTVITranscriptionMessageData(
text=frame.text,
user_id=frame.user_id,
timestamp=frame.timestamp))
timestamp=frame.timestamp,
final=True))
elif isinstance(frame, InterimTranscriptionFrame):
message = RTVIInterimTranscriptionMessage(
message = RTVITranscriptionMessage(
data=RTVITranscriptionMessageData(
text=frame.text, user_id=frame.user_id, timestamp=frame.timestamp))
text=frame.text,
user_id=frame.user_id,
timestamp=frame.timestamp,
final=False))
if message:
frame = TransportMessageFrame(message=message.model_dump(exclude_none=True))