diff --git a/ex_app/lib/livetypes.py b/ex_app/lib/livetypes.py index dc9acc2..8ba6cb3 100644 --- a/ex_app/lib/livetypes.py +++ b/ex_app/lib/livetypes.py @@ -58,6 +58,7 @@ def __init__(self, message: str, retcode: int = 500): # data carrier in the transcript_queue @dataclasses.dataclass class Transcript: + final: bool lang_id: str message: str speaker_session_id: str diff --git a/ex_app/lib/spreed_client.py b/ex_app/lib/spreed_client.py index a8b6bc8..7a41b0a 100644 --- a/ex_app/lib/spreed_client.py +++ b/ex_app/lib/spreed_client.py @@ -311,6 +311,7 @@ async def send_transcript(self, transcript: Transcript): "sessionid": sid, }, "data": { + "final": transcript.final, "langId": transcript.lang_id, "message": transcript.message, "speakerSessionId": transcript.speaker_session_id, diff --git a/ex_app/lib/transcriber.py b/ex_app/lib/transcriber.py index 4cc051b..ea5edbe 100644 --- a/ex_app/lib/transcriber.py +++ b/ex_app/lib/transcriber.py @@ -194,11 +194,18 @@ async def __run_audio_xfer(self, stream: AudioStream): # noqa: C901 }) continue - message = json_msg.get("text", "") + if "partial" in json_msg: + message = json_msg["partial"] + elif "text" in json_msg: + message = json_msg["text"] + else: + message = "" + if message == "": continue self.__transcript_queue.put_nowait(Transcript( + final=("text" in json_msg), lang_id=self.__language, message=message, speaker_session_id=self.__session_id,