examples: more translation-chatbot fixes
This commit is contained in:
@@ -10,8 +10,8 @@ This app connects you to a chatbot powered by GPT-4, complete with animations ge
|
|||||||
## Get started
|
## Get started
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python3 -m venv .venv
|
python3 -m venv venv
|
||||||
source .venv/bin/activate
|
source venv/bin/activate
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
cp env.example .env # and add your credentials
|
cp env.example .env # and add your credentials
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ And a quick video walkthrough of the code: https://www.loom.com/share/13df196716
|
|||||||
## Get started
|
## Get started
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python3 -m venv .venv
|
python3 -m venv venv
|
||||||
source .venv/bin/activate
|
source venv/bin/activate
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
cp env.example .env # and add your credentials
|
cp env.example .env # and add your credentials
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ See a quick video walkthrough of the code here: https://www.loom.com/share/59fdd
|
|||||||
## Get started
|
## Get started
|
||||||
|
|
||||||
```python
|
```python
|
||||||
python3 -m venv env
|
python3 -m venv venv
|
||||||
source env/bin/activate
|
source venv/bin/activate
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
cp env.example .env # and add your credentials
|
cp env.example .env # and add your credentials
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import aiohttp
|
|||||||
import os
|
import os
|
||||||
import sys
|
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.pipeline import Pipeline
|
||||||
from pipecat.pipeline.runner import PipelineRunner
|
from pipecat.pipeline.runner import PipelineRunner
|
||||||
from pipecat.pipeline.task import PipelineTask
|
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):
|
class TranslationProcessor(FrameProcessor):
|
||||||
|
|
||||||
def __init__(self, language):
|
def __init__(self, language):
|
||||||
|
super().__init__()
|
||||||
self._language = language
|
self._language = language
|
||||||
|
|
||||||
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
@@ -54,8 +55,15 @@ class TranslationProcessor(FrameProcessor):
|
|||||||
|
|
||||||
class TranslationSubtitles(FrameProcessor):
|
class TranslationSubtitles(FrameProcessor):
|
||||||
def __init__(self, language):
|
def __init__(self, language):
|
||||||
|
super().__init__()
|
||||||
self._language = language
|
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):
|
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
||||||
if isinstance(frame, TextFrame):
|
if isinstance(frame, TextFrame):
|
||||||
message = {
|
message = {
|
||||||
@@ -76,6 +84,7 @@ async def main(room_url: str, token):
|
|||||||
DailyParams(
|
DailyParams(
|
||||||
audio_out_enabled=True,
|
audio_out_enabled=True,
|
||||||
transcription_enabled=True,
|
transcription_enabled=True,
|
||||||
|
transcription_interim_results=False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -98,6 +107,10 @@ async def main(room_url: str, token):
|
|||||||
|
|
||||||
task = PipelineTask(pipeline)
|
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()
|
runner = PipelineRunner()
|
||||||
|
|
||||||
await runner.run(task)
|
await runner.run(task)
|
||||||
|
|||||||
Reference in New Issue
Block a user