examples: more translation-chatbot fixes

This commit is contained in:
Aleix Conchillo Flaqué
2024-05-13 17:57:11 -07:00
parent 9aea8e951c
commit 68f0da26b6
4 changed files with 20 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)