Skip to content

Commit

Permalink
rebase continued
Browse files Browse the repository at this point in the history
  • Loading branch information
Moishe committed Mar 20, 2024
1 parent c47e085 commit 397bd2d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/foundational/websocket-server/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import asyncio
import aiohttp
import logging
import os

from dailyai.pipeline.frames import TextFrame
from dailyai.pipeline.pipeline import Pipeline
from dailyai.services.elevenlabs_ai_service import ElevenLabsTTSService
from dailyai.services.websocket_transport_service import WebsocketTransportService

from runner import configure

logging.basicConfig(format=f"%(levelno)s %(asctime)s %(message)s")
logger = logging.getLogger("websockets.server")
logger.setLevel(logging.DEBUG)


async def main(room_url):
async with aiohttp.ClientSession() as session:
transport = WebsocketTransportService(
mic_enabled=True, speaker_enabled=True)

tts = ElevenLabsTTSService(
aiohttp_session=session,
api_key=os.getenv("ELEVENLABS_API_KEY"),
voice_id=os.getenv("ELEVENLABS_VOICE_ID"),
)

pipeline = Pipeline([tts])

@transport.on_connection
async def queue_frame():
await pipeline.queue_frames([TextFrame("Hello there!")])

await asyncio.gather(transport.run(pipeline))
del tts


if __name__ == "__main__":
(url, token) = configure()
asyncio.run(main(url))

0 comments on commit 397bd2d

Please sign in to comment.