Skip to content

Commit 39d63db

Browse files
committed
add runner.py
1 parent dcee996 commit 39d63db

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ There are also two disadvantages to using WebRTC this way.
9898
│ │ │ │ ▼ │ │
9999
│ Pipecat Client │ │ ┌─────────────│ Gemini Flash ─┼──┼────►
100100
│ ┌───────────────┐ │ │ │ │ Transcription ◄┼──┼─────
101-
│ │ WebRTC (Daily)│ ────┼────────►│WebRTC (Daily ▼ │ │
101+
│ │ WebRTC (Daily)│ ────┼────────►│WebRTC (Daily) ▼ │ │
102102
│ │ Transport │ ◄───┼─────────│ Transport │ Gemini Multimodal─┼──┼────►
103103
│ └───────────────┘ │ │ │ │ Live API ◄┼──┼─────
104104
│ │ │ └─────────────│ ▼ │ │

server/runner.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# Copyright (c) 2024, Daily
3+
#
4+
# SPDX-License-Identifier: BSD 2-Clause License
5+
#
6+
7+
import argparse
8+
import os
9+
10+
import aiohttp
11+
12+
from pipecat.transports.services.helpers.daily_rest import DailyRESTHelper
13+
14+
15+
async def configure(aiohttp_session: aiohttp.ClientSession):
16+
"""Configure the Daily room and Daily REST helper."""
17+
parser = argparse.ArgumentParser(description="Daily AI SDK Bot Sample")
18+
parser.add_argument(
19+
"-u", "--url", type=str, required=False, help="URL of the Daily room to join"
20+
)
21+
parser.add_argument(
22+
"-k",
23+
"--apikey",
24+
type=str,
25+
required=False,
26+
help="Daily API Key (needed to create an owner token for the room)",
27+
)
28+
29+
args, unknown = parser.parse_known_args()
30+
31+
url = args.url or os.getenv("DAILY_SAMPLE_ROOM_URL")
32+
key = args.apikey or os.getenv("DAILY_API_KEY")
33+
34+
if not url:
35+
raise Exception(
36+
"No Daily room specified. use the -u/--url option from the command line, or set DAILY_SAMPLE_ROOM_URL in your environment to specify a Daily room URL."
37+
)
38+
39+
if not key:
40+
raise Exception(
41+
"No Daily API key specified. use the -k/--apikey option from the command line, or set DAILY_API_KEY in your environment to specify a Daily API key, available from https://dashboard.daily.co/developers."
42+
)
43+
44+
daily_rest_helper = DailyRESTHelper(
45+
daily_api_key=key,
46+
daily_api_url=os.getenv("DAILY_API_URL", "https://api.daily.co/v1"),
47+
aiohttp_session=aiohttp_session,
48+
)
49+
50+
# Create a meeting token for the given room with an expiration 1 hour in
51+
# the future.
52+
expiry_time: float = 60 * 60
53+
54+
token = await daily_rest_helper.get_token(url, expiry_time)
55+
56+
return (url, token)

0 commit comments

Comments
 (0)