examples(foundational): update handle_signint depending on transport
This commit is contained in:
@@ -75,7 +75,7 @@ transport_params = {
|
||||
}
|
||||
|
||||
|
||||
async def run_example(transport: BaseTransport, _: argparse.Namespace):
|
||||
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
|
||||
logger.info(f"Starting bot")
|
||||
|
||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||
@@ -160,7 +160,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace):
|
||||
logger.info(f"Client closed connection")
|
||||
await task.cancel()
|
||||
|
||||
runner = PipelineRunner(handle_sigint=False)
|
||||
runner = PipelineRunner(handle_sigint=handle_sigint)
|
||||
|
||||
await runner.run(task)
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ transport_params = {
|
||||
}
|
||||
|
||||
|
||||
async def run_example(transport: BaseTransport, _: argparse.Namespace):
|
||||
async def run_example(transport: BaseTransport, _: argparse.Namespace, handle_sigint: bool):
|
||||
logger.info(f"Starting bot")
|
||||
|
||||
stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"))
|
||||
@@ -158,7 +158,7 @@ async def run_example(transport: BaseTransport, _: argparse.Namespace):
|
||||
logger.info(f"Client closed connection")
|
||||
await task.cancel()
|
||||
|
||||
runner = PipelineRunner(handle_sigint=False)
|
||||
runner = PipelineRunner(handle_sigint=handle_sigint)
|
||||
|
||||
await runner.run(task)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ def run_example_daily(
|
||||
|
||||
# Run example function with DailyTransport transport arguments.
|
||||
transport = DailyTransport(room_url, token, "Pipecat", params=params)
|
||||
await run_example(transport, args)
|
||||
await run_example(transport, args, True)
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
@@ -103,7 +103,7 @@ def run_example_webrtc(
|
||||
|
||||
# Run example function with SmallWebRTC transport arguments.
|
||||
transport = SmallWebRTCTransport(params=params, webrtc_connection=pipecat_connection)
|
||||
background_tasks.add_task(run_example, transport, args)
|
||||
background_tasks.add_task(run_example, transport, args, False)
|
||||
|
||||
answer = pipecat_connection.get_answer()
|
||||
# Updating the peer connection inside the map
|
||||
@@ -175,7 +175,7 @@ def run_example_twilio(
|
||||
auth_token=os.getenv("TWILIO_AUTH_TOKEN", ""),
|
||||
)
|
||||
transport = FastAPIWebsocketTransport(websocket=websocket, params=params)
|
||||
await run_example(transport, args)
|
||||
await run_example(transport, args, False)
|
||||
|
||||
uvicorn.run(app, host=args.host, port=args.port)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user