Add interruptions
This commit is contained in:
@@ -14,6 +14,8 @@ from loguru import logger
|
|||||||
from runner import configure
|
from runner import configure
|
||||||
|
|
||||||
from pipecat.frames.frames import (
|
from pipecat.frames.frames import (
|
||||||
|
StartInterruptionFrame,
|
||||||
|
StopInterruptionFrame,
|
||||||
TranscriptionFrame,
|
TranscriptionFrame,
|
||||||
UserStartedSpeakingFrame,
|
UserStartedSpeakingFrame,
|
||||||
UserStoppedSpeakingFrame,
|
UserStoppedSpeakingFrame,
|
||||||
@@ -72,13 +74,23 @@ async def main():
|
|||||||
# participant joins.
|
# participant joins.
|
||||||
@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):
|
||||||
frames = [
|
# Create frames for 3 seconds
|
||||||
UserStartedSpeakingFrame(),
|
start_time = time.time()
|
||||||
TranscriptionFrame("Tell a joke about dogs.", "user_id", time.time()),
|
while time.time() - start_time < 300:
|
||||||
UserStoppedSpeakingFrame(),
|
timestamp = time.time()
|
||||||
]
|
frames = [
|
||||||
|
UserStartedSpeakingFrame(),
|
||||||
await task.queue_frames(frames)
|
TranscriptionFrame("Tell a joke about dogs.", "user_id", timestamp),
|
||||||
|
UserStoppedSpeakingFrame(),
|
||||||
|
]
|
||||||
|
await task.queue_frames(frames)
|
||||||
|
await asyncio.sleep(5) # Small delay between frame sets
|
||||||
|
next_frames = [
|
||||||
|
StartInterruptionFrame(),
|
||||||
|
TranscriptionFrame("Tell a joke about cats.", "user_id", timestamp),
|
||||||
|
StopInterruptionFrame(),
|
||||||
|
]
|
||||||
|
await task.queue_frames(next_frames)
|
||||||
|
|
||||||
await runner.run(task)
|
await runner.run(task)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user