frames: add language to transcription frames
This commit is contained in:
@@ -8,6 +8,7 @@ from typing import Any, List, Mapping, Optional, Tuple
|
|||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
from pipecat.transcriptions.languages import Language
|
||||||
from pipecat.utils.utils import obj_count, obj_id
|
from pipecat.utils.utils import obj_count, obj_id
|
||||||
from pipecat.vad.vad_analyzer import VADParams
|
from pipecat.vad.vad_analyzer import VADParams
|
||||||
|
|
||||||
@@ -131,9 +132,10 @@ class TranscriptionFrame(TextFrame):
|
|||||||
"""
|
"""
|
||||||
user_id: str
|
user_id: str
|
||||||
timestamp: str
|
timestamp: str
|
||||||
|
language: Language | None = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}(user: {self.user_id}, text: {self.text}, timestamp: {self.timestamp})"
|
return f"{self.name}(user: {self.user_id}, text: {self.text}, language: {self.language}, timestamp: {self.timestamp})"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -142,9 +144,10 @@ class InterimTranscriptionFrame(TextFrame):
|
|||||||
the transport's receive queue when a participant speaks."""
|
the transport's receive queue when a participant speaks."""
|
||||||
user_id: str
|
user_id: str
|
||||||
timestamp: str
|
timestamp: str
|
||||||
|
language: Language | None = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}(user: {self.user_id}, text: {self.text}, timestamp: {self.timestamp})"
|
return f"{self.name}(user: {self.user_id}, text: {self.text}, language: {self.language}, timestamp: {self.timestamp})"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
23
src/pipecat/transcriptions/language.py
Normal file
23
src/pipecat/transcriptions/language.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# Copyright (c) 2024, Daily
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD 2-Clause License
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
if sys.version_info < (3, 11):
|
||||||
|
class StrEnum(str, Enum):
|
||||||
|
def __new__(cls, value):
|
||||||
|
obj = str.__new__(cls, value)
|
||||||
|
obj._value_ = value
|
||||||
|
return obj
|
||||||
|
else:
|
||||||
|
from enum import StrEnum
|
||||||
|
|
||||||
|
|
||||||
|
class Language(StrEnum):
|
||||||
|
EN = "en"
|
||||||
|
ES = "es"
|
||||||
Reference in New Issue
Block a user