examples: remove RTVI since there are full demos elsewhere
This commit is contained in:
@@ -1,78 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 2024, Daily
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD 2-Clause License
|
|
||||||
#
|
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
from pipecat.pipeline.pipeline import Pipeline
|
|
||||||
from pipecat.pipeline.task import PipelineParams, PipelineTask
|
|
||||||
from pipecat.pipeline.runner import PipelineRunner
|
|
||||||
from pipecat.processors.frameworks.rtvi import (
|
|
||||||
RTVIConfig,
|
|
||||||
RTVILLMConfig,
|
|
||||||
RTVIProcessor,
|
|
||||||
RTVISetup,
|
|
||||||
RTVITTSConfig)
|
|
||||||
from pipecat.transports.services.daily import DailyParams, DailyTransport
|
|
||||||
from pipecat.vad.silero import SileroVADAnalyzer
|
|
||||||
|
|
||||||
from runner import configure
|
|
||||||
|
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv(override=True)
|
|
||||||
|
|
||||||
logger.remove(0)
|
|
||||||
logger.add(sys.stderr, level="DEBUG")
|
|
||||||
|
|
||||||
|
|
||||||
async def main(room_url, token):
|
|
||||||
transport = DailyTransport(
|
|
||||||
room_url,
|
|
||||||
token,
|
|
||||||
"Realtime AI",
|
|
||||||
DailyParams(
|
|
||||||
audio_out_enabled=True,
|
|
||||||
transcription_enabled=True,
|
|
||||||
vad_enabled=True,
|
|
||||||
vad_analyzer=SileroVADAnalyzer()
|
|
||||||
))
|
|
||||||
|
|
||||||
llm = RTVILLMConfig(
|
|
||||||
model="llama3-70b-8192",
|
|
||||||
messages=[{"role": "system", "content": "You are a helpful assistant named Gary. Briefly say hello!"}]
|
|
||||||
)
|
|
||||||
tts = RTVITTSConfig(voice="79a125e8-cd45-4c13-8a67-188112f4dd22")
|
|
||||||
setup = RTVISetup(config=RTVIConfig(llm=llm, tts=tts))
|
|
||||||
|
|
||||||
rtai = RTVIProcessor(
|
|
||||||
transport=transport,
|
|
||||||
setup=setup,
|
|
||||||
llm_api_key=os.getenv("OPENAI_API_KEY"),
|
|
||||||
tts_api_key=os.getenv("CARTESIA_API_KEY"))
|
|
||||||
|
|
||||||
runner = PipelineRunner()
|
|
||||||
|
|
||||||
pipeline = Pipeline([transport.input(), rtai])
|
|
||||||
|
|
||||||
task = PipelineTask(
|
|
||||||
pipeline,
|
|
||||||
params=PipelineParams(
|
|
||||||
allow_interruptions=True,
|
|
||||||
enable_metrics=True,
|
|
||||||
report_only_initial_ttfb=True))
|
|
||||||
|
|
||||||
@transport.event_handler("on_participant_joined")
|
|
||||||
async def on_participant_joined(transport, participant):
|
|
||||||
transport.capture_participant_transcription(participant["id"])
|
|
||||||
|
|
||||||
await runner.run(task)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
(url, token) = configure()
|
|
||||||
asyncio.run(main(url, token))
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import argparse
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import urllib
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
def configure():
|
|
||||||
parser = argparse.ArgumentParser(description="Daily AI SDK Bot Sample")
|
|
||||||
parser.add_argument(
|
|
||||||
"-u",
|
|
||||||
"--url",
|
|
||||||
type=str,
|
|
||||||
required=False,
|
|
||||||
help="URL of the Daily room to join")
|
|
||||||
parser.add_argument(
|
|
||||||
"-k",
|
|
||||||
"--apikey",
|
|
||||||
type=str,
|
|
||||||
required=False,
|
|
||||||
help="Daily API Key (needed to create an owner token for the room)",
|
|
||||||
)
|
|
||||||
|
|
||||||
args, unknown = parser.parse_known_args()
|
|
||||||
|
|
||||||
url = args.url or os.getenv("DAILY_SAMPLE_ROOM_URL")
|
|
||||||
key = args.apikey or os.getenv("DAILY_API_KEY")
|
|
||||||
|
|
||||||
if not url:
|
|
||||||
raise Exception(
|
|
||||||
"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.")
|
|
||||||
|
|
||||||
if not key:
|
|
||||||
raise Exception("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.")
|
|
||||||
|
|
||||||
# Create a meeting token for the given room with an expiration 1 hour in
|
|
||||||
# the future.
|
|
||||||
room_name: str = urllib.parse.urlparse(url).path[1:]
|
|
||||||
expiration: float = time.time() + 60 * 60
|
|
||||||
|
|
||||||
res: requests.Response = requests.post(
|
|
||||||
f"https://api.daily.co/v1/meeting-tokens",
|
|
||||||
headers={
|
|
||||||
"Authorization": f"Bearer {key}"},
|
|
||||||
json={
|
|
||||||
"properties": {
|
|
||||||
"room_name": room_name,
|
|
||||||
"is_owner": True,
|
|
||||||
"exp": expiration}},
|
|
||||||
)
|
|
||||||
|
|
||||||
if res.status_code != 200:
|
|
||||||
raise Exception(
|
|
||||||
f"Failed to create meeting token: {res.status_code} {res.text}")
|
|
||||||
|
|
||||||
token: str = res.json()["token"]
|
|
||||||
|
|
||||||
return (url, token)
|
|
||||||
Reference in New Issue
Block a user