From 0db2cf5a80a42946f74f482f195729d66d1c6d5a Mon Sep 17 00:00:00 2001 From: Kwindla Hultman Kramer Date: Mon, 1 Jan 2024 21:46:10 -0800 Subject: [PATCH] working on theoretical API examples --- .../{ => functional}/just-say-one-thing.py | 0 .../theoretical/01-say-one-thing.py | 47 +++++++++++++++++++ .../theoretical/02-llm-say-one-thing.py | 47 +++++++++++++++++++ src/khk-working/theoretical/notes.txt | 14 ++++++ 4 files changed, 108 insertions(+) rename src/khk-working/{ => functional}/just-say-one-thing.py (100%) create mode 100644 src/khk-working/theoretical/01-say-one-thing.py create mode 100644 src/khk-working/theoretical/02-llm-say-one-thing.py create mode 100644 src/khk-working/theoretical/notes.txt diff --git a/src/khk-working/just-say-one-thing.py b/src/khk-working/functional/just-say-one-thing.py similarity index 100% rename from src/khk-working/just-say-one-thing.py rename to src/khk-working/functional/just-say-one-thing.py diff --git a/src/khk-working/theoretical/01-say-one-thing.py b/src/khk-working/theoretical/01-say-one-thing.py new file mode 100644 index 000000000..431e91db3 --- /dev/null +++ b/src/khk-working/theoretical/01-say-one-thing.py @@ -0,0 +1,47 @@ + +from dailyai.services.transport.DailyTransport import DailyTransportService +from dailyai.services.tts.AzureTTSService import AzureTTSService + + +transport = None +tts = None + + +def main(): + global transport + global tts + + # create a transport service object using environment variables for + # the transport service's API key, room url, and any other configuration. + # services can all define and document the environment variables they use. + # services all also take an optional config object that is used instead of + # environment variables. + # + # the abstract transport service APIs presumably can map pretty closely + # to the daily-python basic API + transport = DailyTransportService() + + # similarly, create a tts service + tts = AzureTTSService() + + # ask the transport to create a local audio "device"/queue for + # chunks of audio to play sequentially. the "mic" object is a handle + # we can use to inspect and control the queue if we need to. in this + # case we will pipe into this queue from the tts service + mic = transport.audio_queue() + tts.set_output(mic) + + transport.on("error", lambda e: print(e)) + transport.on("joined-meeting", say_one_thing) + transport.start() + + +def say_one_thing(): + # say one thing, then leave + tts.run_tts("hello world") + transport.on("audio-queue-empty", shutdown) + + +def shutdown(): + transport.stop() + tts.close() diff --git a/src/khk-working/theoretical/02-llm-say-one-thing.py b/src/khk-working/theoretical/02-llm-say-one-thing.py new file mode 100644 index 000000000..dbc8b7392 --- /dev/null +++ b/src/khk-working/theoretical/02-llm-say-one-thing.py @@ -0,0 +1,47 @@ + +from dailyai.services.transport.DailyTransport import DailyTransportService +from dailyai.services.llm.AzureLLMService import AzureLLMService +from dailyai.services.tts.AzureTTSService import AzureTTSService + +transport = None +mic = None +llm = None +tts = None + + +def main(): + global transport + global mic + global llm + global tts + + transport = DailyTransportService() + llm = AzureLLMService() + tts = AzureTTSService() + mic = transport.audio_queue() + tts.set_output(mic) + + # similarly, we can tell the llm to pipe infeference output to our tts + # service. the design idea here is that any time we call llm.run_llm() + # we are creating a cancelable inference call, and somehow behind the + # scenes the full pipeline from the llm to the tts service to the + # transport's audio queue is managed in such a way as to be + # introspectible and cancelable. also, instead of piping the + # output to the tts service directly, we could pipe it through an + # adapter object that does chunking or processing or whatever. + llm.set_output(tts) + + transport.on("error", lambda e: print(e)) + transport.on("joined-meeting", make_one_inference_call) + transport.start() + + +def make_one_inference_call(): + # ask our llm to say one thing, then leave + llm.run_llm("tell me a joke about llamas") + transport.on("audio-queue-empty", shutdown) + + +def shutdown(): + transport.stop() + tts.close() diff --git a/src/khk-working/theoretical/notes.txt b/src/khk-working/theoretical/notes.txt new file mode 100644 index 000000000..a795fab10 --- /dev/null +++ b/src/khk-working/theoretical/notes.txt @@ -0,0 +1,14 @@ + +-01 just say one thing and exit +-02 llm say one thing and exit +-03 send "still frame" video +-04 manual intro utterance and then llm say one thing and exit +-05 queue 10 spoken image prompts and synchronize the audio with the generated image frames +-06 chat: llm speak and respond (ignoring transcription input while speaking) +-07 chat: llm speak and respond (interruptible) +-08 two llms arguing about a topic (in the same process) +-09 two llms arguing about a topic (two separate bots) +-10 listen for wake word before sending commands to llm +-11 06 plus sound effects queued from sound file +-12 06 plus background music played through a second "mic" device +