Add TranslationFrame and use in GladiaSTTService; add 13c-gladia-translation.py
This commit is contained in:
@@ -256,6 +256,22 @@ class InterimTranscriptionFrame(TextFrame):
|
||||
return f"{self.name}(user: {self.user_id}, text: [{self.text}], language: {self.language}, timestamp: {self.timestamp})"
|
||||
|
||||
|
||||
@dataclass
|
||||
class TranslationFrame(TextFrame):
|
||||
"""A text frame with translated transcription data.
|
||||
|
||||
Will be placed in the transport's receive queue when a participant speaks.
|
||||
|
||||
"""
|
||||
|
||||
user_id: str
|
||||
timestamp: str
|
||||
language: Optional[Language] = None
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}(user: {self.user_id}, text: [{self.text}], language: {self.language}, timestamp: {self.timestamp})"
|
||||
|
||||
|
||||
@dataclass
|
||||
class OpenAILLMContextAssistantTimestampFrame(DataFrame):
|
||||
"""Timestamp information for assistant message in LLM context."""
|
||||
|
||||
@@ -20,6 +20,7 @@ from pipecat.frames.frames import (
|
||||
InterimTranscriptionFrame,
|
||||
StartFrame,
|
||||
TranscriptionFrame,
|
||||
TranslationFrame,
|
||||
)
|
||||
from pipecat.services.gladia.config import GladiaInputParams
|
||||
from pipecat.services.stt_service import STTService
|
||||
@@ -405,7 +406,7 @@ class GladiaSTTService(STTService):
|
||||
translation = translated_utterance["text"]
|
||||
if translated_language != original_language and confidence >= self._confidence:
|
||||
await self.push_frame(
|
||||
TranscriptionFrame(
|
||||
TranslationFrame(
|
||||
translation, "", time_now_iso8601(), translated_language
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user