fixedup gpt4o and gemini-flash examples with interruption changes

This commit is contained in:
Kwindla Hultman Kramer
2024-05-18 15:01:34 -07:00
parent 6d8dc732e1
commit 05f44bf4c3
2 changed files with 29 additions and 15 deletions

View File

@@ -19,7 +19,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.services.elevenlabs import ElevenLabsTTSService from pipecat.services.elevenlabs import ElevenLabsTTSService
from pipecat.services.google import GoogleLLMService from pipecat.services.google import GoogleLLMService
from pipecat.transports.services.daily import DailyParams, DailyTransport from pipecat.transports.services.daily import DailyParams, DailyTransport
from pipecat.vad.silero import SileroVAD from pipecat.vad.silero import SileroVADAnalyzer
from runner import configure from runner import configure
@@ -56,12 +56,12 @@ async def main(room_url: str, token):
DailyParams( DailyParams(
audio_in_enabled=True, # This is so Silero VAD can get audio data audio_in_enabled=True, # This is so Silero VAD can get audio data
audio_out_enabled=True, audio_out_enabled=True,
transcription_enabled=True transcription_enabled=True,
vad_enabled=True,
vad_analyzer=SileroVADAnalyzer()
) )
) )
vad = SileroVAD()
tts = ElevenLabsTTSService( tts = ElevenLabsTTSService(
aiohttp_session=session, aiohttp_session=session,
api_key=os.getenv("ELEVENLABS_API_KEY"), api_key=os.getenv("ELEVENLABS_API_KEY"),
@@ -89,10 +89,17 @@ async def main(room_url: str, token):
transport.capture_participant_transcription(participant["id"]) transport.capture_participant_transcription(participant["id"])
image_requester.set_participant_id(participant["id"]) image_requester.set_participant_id(participant["id"])
pipeline = Pipeline([transport.input(), vad, user_response, image_requester, pipeline = Pipeline([
vision_aggregator, google, tts, transport.output()]) transport.input(),
user_response,
image_requester,
vision_aggregator,
google,
tts,
transport.output()
])
task = PipelineTask(pipeline) task = PipelineTask(pipeline, allow_interruptions=True)
runner = PipelineRunner() runner = PipelineRunner()

View File

@@ -19,7 +19,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
from pipecat.services.elevenlabs import ElevenLabsTTSService from pipecat.services.elevenlabs import ElevenLabsTTSService
from pipecat.services.openai import OpenAILLMService from pipecat.services.openai import OpenAILLMService
from pipecat.transports.services.daily import DailyParams, DailyTransport from pipecat.transports.services.daily import DailyParams, DailyTransport
from pipecat.vad.silero import SileroVAD from pipecat.vad.silero import SileroVADAnalyzer
from runner import configure from runner import configure
@@ -56,12 +56,12 @@ async def main(room_url: str, token):
DailyParams( DailyParams(
audio_in_enabled=True, # This is so Silero VAD can get audio data audio_in_enabled=True, # This is so Silero VAD can get audio data
audio_out_enabled=True, audio_out_enabled=True,
transcription_enabled=True transcription_enabled=True,
vad_enabled=True,
vad_analyzer=SileroVADAnalyzer()
) )
) )
vad = SileroVAD()
tts = ElevenLabsTTSService( tts = ElevenLabsTTSService(
aiohttp_session=session, aiohttp_session=session,
api_key=os.getenv("ELEVENLABS_API_KEY"), api_key=os.getenv("ELEVENLABS_API_KEY"),
@@ -74,7 +74,7 @@ async def main(room_url: str, token):
vision_aggregator = VisionImageFrameAggregator() vision_aggregator = VisionImageFrameAggregator()
google = OpenAILLMService( gpt4o = OpenAILLMService(
api_key=os.getenv("OPENAI_API_KEY"), api_key=os.getenv("OPENAI_API_KEY"),
model="gpt-4o" model="gpt-4o"
) )
@@ -92,10 +92,17 @@ async def main(room_url: str, token):
transport.capture_participant_transcription(participant["id"]) transport.capture_participant_transcription(participant["id"])
image_requester.set_participant_id(participant["id"]) image_requester.set_participant_id(participant["id"])
pipeline = Pipeline([transport.input(), vad, user_response, image_requester, pipeline = Pipeline([
vision_aggregator, google, tts, transport.output()]) transport.input(),
user_response,
image_requester,
vision_aggregator,
gpt4o,
tts,
transport.output()
])
task = PipelineTask(pipeline) task = PipelineTask(pipeline, allow_interruptions=True)
runner = PipelineRunner() runner = PipelineRunner()