From 68f0da26b6e5d285fa1e2b8cb0487d882e731bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 13 May 2024 17:57:11 -0700 Subject: [PATCH] examples: more translation-chatbot fixes --- examples/moondream-chatbot/README.md | 4 ++-- examples/simple-chatbot/README.md | 4 ++-- examples/translation-chatbot/README.md | 4 ++-- examples/translation-chatbot/bot.py | 15 ++++++++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/examples/moondream-chatbot/README.md b/examples/moondream-chatbot/README.md index a1ec5377a..53f7f84dd 100644 --- a/examples/moondream-chatbot/README.md +++ b/examples/moondream-chatbot/README.md @@ -10,8 +10,8 @@ This app connects you to a chatbot powered by GPT-4, complete with animations ge ## Get started ```python -python3 -m venv .venv -source .venv/bin/activate +python3 -m venv venv +source venv/bin/activate pip install -r requirements.txt cp env.example .env # and add your credentials diff --git a/examples/simple-chatbot/README.md b/examples/simple-chatbot/README.md index 230ff0c43..13c0b31e0 100644 --- a/examples/simple-chatbot/README.md +++ b/examples/simple-chatbot/README.md @@ -13,8 +13,8 @@ And a quick video walkthrough of the code: https://www.loom.com/share/13df196716 ## Get started ```python -python3 -m venv .venv -source .venv/bin/activate +python3 -m venv venv +source venv/bin/activate pip install -r requirements.txt cp env.example .env # and add your credentials diff --git a/examples/translation-chatbot/README.md b/examples/translation-chatbot/README.md index 7a141b334..ff25117ea 100644 --- a/examples/translation-chatbot/README.md +++ b/examples/translation-chatbot/README.md @@ -9,8 +9,8 @@ See a quick video walkthrough of the code here: https://www.loom.com/share/59fdd ## Get started ```python -python3 -m venv env -source env/bin/activate +python3 -m venv venv +source venv/bin/activate pip install -r requirements.txt cp env.example .env # and add your credentials diff --git a/examples/translation-chatbot/bot.py b/examples/translation-chatbot/bot.py index 6b41166e1..376b3570e 100644 --- a/examples/translation-chatbot/bot.py +++ b/examples/translation-chatbot/bot.py @@ -3,7 +3,7 @@ import aiohttp import os import sys -from pipecat.frames.frames import Frame, LLMMessagesFrame, TextFrame, TransportMessageFrame +from pipecat.frames.frames import Frame, InterimTranscriptionFrame, LLMMessagesFrame, TextFrame, TranscriptionFrame, TransportMessageFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask @@ -36,6 +36,7 @@ It also isn't saving what the user or bot says into the context object for use i class TranslationProcessor(FrameProcessor): def __init__(self, language): + super().__init__() self._language = language async def process_frame(self, frame: Frame, direction: FrameDirection): @@ -54,8 +55,15 @@ class TranslationProcessor(FrameProcessor): class TranslationSubtitles(FrameProcessor): def __init__(self, language): + super().__init__() self._language = language + # + # This doesn't do anything unless the receiver recognizes the message being + # sent. For example, in this case, we are sending a message to the transport + # so an application running at the other end of the transport could display + # subtitles. + # async def process_frame(self, frame: Frame, direction: FrameDirection): if isinstance(frame, TextFrame): message = { @@ -76,6 +84,7 @@ async def main(room_url: str, token): DailyParams( audio_out_enabled=True, transcription_enabled=True, + transcription_interim_results=False, ) ) @@ -98,6 +107,10 @@ async def main(room_url: str, token): task = PipelineTask(pipeline) + @transport.event_handler("on_first_participant_joined") + async def on_first_participant_joined(transport, participant): + transport.capture_participant_transcription(participant["id"]) + runner = PipelineRunner() await runner.run(task)