Add an RTVIProcessor to the simple-chatbot pipeline
This commit is contained in:
@@ -42,6 +42,8 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask
|
|||||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
from pipecat.processors.frameworks.rtvi import (
|
from pipecat.processors.frameworks.rtvi import (
|
||||||
|
RTVIProcessor,
|
||||||
|
RTVIConfig,
|
||||||
RTVIBotTranscriptionProcessor,
|
RTVIBotTranscriptionProcessor,
|
||||||
RTVIMetricsProcessor,
|
RTVIMetricsProcessor,
|
||||||
RTVISpeakingProcessor,
|
RTVISpeakingProcessor,
|
||||||
@@ -179,9 +181,13 @@ async def main():
|
|||||||
# This will send `metrics` messages.
|
# This will send `metrics` messages.
|
||||||
rtvi_metrics = RTVIMetricsProcessor()
|
rtvi_metrics = RTVIMetricsProcessor()
|
||||||
|
|
||||||
|
# Handles RTVI messages from the client
|
||||||
|
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))
|
||||||
|
|
||||||
pipeline = Pipeline(
|
pipeline = Pipeline(
|
||||||
[
|
[
|
||||||
transport.input(),
|
transport.input(),
|
||||||
|
rtvi,
|
||||||
context_aggregator.user(),
|
context_aggregator.user(),
|
||||||
llm,
|
llm,
|
||||||
rtvi_speaking,
|
rtvi_speaking,
|
||||||
@@ -204,6 +210,10 @@ async def main():
|
|||||||
)
|
)
|
||||||
await task.queue_frame(quiet_frame)
|
await task.queue_frame(quiet_frame)
|
||||||
|
|
||||||
|
@rtvi.event_handler("on_client_ready")
|
||||||
|
async def on_client_ready(rtvi):
|
||||||
|
await rtvi.set_bot_ready()
|
||||||
|
|
||||||
@transport.event_handler("on_first_participant_joined")
|
@transport.event_handler("on_first_participant_joined")
|
||||||
async def on_first_participant_joined(transport, participant):
|
async def on_first_participant_joined(transport, participant):
|
||||||
await transport.capture_participant_transcription(participant["id"])
|
await transport.capture_participant_transcription(participant["id"])
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask
|
|||||||
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext
|
||||||
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
||||||
from pipecat.processors.frameworks.rtvi import (
|
from pipecat.processors.frameworks.rtvi import (
|
||||||
|
RTVIProcessor,
|
||||||
RTVIBotTranscriptionProcessor,
|
RTVIBotTranscriptionProcessor,
|
||||||
RTVIMetricsProcessor,
|
RTVIMetricsProcessor,
|
||||||
RTVISpeakingProcessor,
|
RTVISpeakingProcessor,
|
||||||
RTVIUserTranscriptionProcessor,
|
RTVIUserTranscriptionProcessor,
|
||||||
|
RTVIConfig,
|
||||||
)
|
)
|
||||||
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
from pipecat.services.elevenlabs import ElevenLabsTTSService
|
||||||
from pipecat.services.openai import OpenAILLMService
|
from pipecat.services.openai import OpenAILLMService
|
||||||
@@ -201,9 +203,13 @@ async def main():
|
|||||||
# This will send `metrics` messages.
|
# This will send `metrics` messages.
|
||||||
rtvi_metrics = RTVIMetricsProcessor()
|
rtvi_metrics = RTVIMetricsProcessor()
|
||||||
|
|
||||||
|
# Handles RTVI messages from the client
|
||||||
|
rtvi = RTVIProcessor(config=RTVIConfig(config=[]))
|
||||||
|
|
||||||
pipeline = Pipeline(
|
pipeline = Pipeline(
|
||||||
[
|
[
|
||||||
transport.input(),
|
transport.input(),
|
||||||
|
rtvi,
|
||||||
rtvi_speaking,
|
rtvi_speaking,
|
||||||
rtvi_user_transcription,
|
rtvi_user_transcription,
|
||||||
context_aggregator.user(),
|
context_aggregator.user(),
|
||||||
@@ -227,6 +233,10 @@ async def main():
|
|||||||
)
|
)
|
||||||
await task.queue_frame(quiet_frame)
|
await task.queue_frame(quiet_frame)
|
||||||
|
|
||||||
|
@rtvi.event_handler("on_client_ready")
|
||||||
|
async def on_client_ready(rtvi):
|
||||||
|
await rtvi.set_bot_ready()
|
||||||
|
|
||||||
@transport.event_handler("on_first_participant_joined")
|
@transport.event_handler("on_first_participant_joined")
|
||||||
async def on_first_participant_joined(transport, participant):
|
async def on_first_participant_joined(transport, participant):
|
||||||
await transport.capture_participant_transcription(participant["id"])
|
await transport.capture_participant_transcription(participant["id"])
|
||||||
|
|||||||
Reference in New Issue
Block a user