-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |