working on theoretical API examples

This commit is contained in:
Kwindla Hultman Kramer
2024-01-01 21:46:10 -08:00
parent 72aa034c85
commit 0db2cf5a80
4 changed files with 108 additions and 0 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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