pipecat
pipecat copied to clipboard
say one thing with ElevenLabsTTSService doesnt work anymore
I replaced the CartesiaTTSService
with ElevenLabsTTSService
in the https://github.com/pipecat-ai/pipecat/blob/main/examples/foundational/01-say-one-thing.py example, but that doesnt work anymore with 0.0.43
Here's some logging output.
❯ pipenv run python ./pipecat/01-say-one-thing.py
Loading .env environment variables...
2024-10-11 16:15:56.950 | DEBUG | pipecat.processors.frame_processor:link:134 - Linking PipelineSource#0 -> ElevenLabsTTSService#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.processors.frame_processor:link:134 - Linking ElevenLabsTTSService#0 -> DailyOutputTransport#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.processors.frame_processor:link:134 - Linking DailyOutputTransport#0 -> PipelineSink#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.processors.frame_processor:link:134 - Linking Source#0 -> Pipeline#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.processors.frame_processor:link:134 - Linking Pipeline#0 -> Sink#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.pipeline.runner:run:27 - Runner PipelineRunner#0 started running PipelineTask#0
2024-10-11 16:15:56.950 | DEBUG | pipecat.services.elevenlabs:_connect:301 - Language code [en] not applied. Language codes can only be used with the 'eleven_turbo_v2_5' model.
2024-10-11 16:15:57.143 | INFO | pipecat.transports.services.daily:join:299 - Joining https://b4mad.daily.co/.....
2024-10-11 16:15:58.041 | INFO | pipecat.transports.services.daily:on_participant_joined:523 - Participant joined f86d7746-c249-447e-9bb3-45192846b589
2024-10-11 16:15:58.786 | INFO | pipecat.transports.services.daily:join:318 - Joined https://b4mad.daily.co/...
2024-10-11 16:15:58.786 | DEBUG | pipecat.services.elevenlabs:run_tts:381 - Generating TTS: [Hello there, Marcel!]
2024-10-11 16:15:58.786 | DEBUG | pipecat.transports.base_output:_bot_started_speaking:333 - Bot started speaking
2024-10-11 16:16:00.790 | DEBUG | pipecat.transports.base_output:_bot_stopped_speaking:338 - Bot stopped speaking
^C2024-10-11 16:16:07.783 | WARNING | pipecat.pipeline.runner:_sig_handler:51 - Interruption detected. Canceling runner PipelineRunner#0
2024-10-11 16:16:07.783 | DEBUG | pipecat.pipeline.runner:cancel:38 - Canceling runner PipelineRunner#0
2024-10-11 16:16:07.783 | DEBUG | pipecat.pipeline.task:cancel:118 - Canceling pipeline task PipelineTask#0
2024-10-11 16:16:07.905 | INFO | pipecat.transports.services.daily:leave:406 - Leaving https://b4mad.daily.co/...
2024-10-11 16:16:07.933 | INFO | pipecat.transports.services.daily:leave:415 - Left https://b4mad.daily.co/...
2024-10-11 16:16:07.934 | DEBUG | pipecat.pipeline.runner:run:31 - Runner PipelineRunner#0 finished running PipelineTask#0
And here's the modified example:
#
# Copyright (c) 2024, Daily
#
# SPDX-License-Identifier: BSD 2-Clause License
#
import asyncio
import aiohttp
import os
import sys
from pipecat.frames.frames import TextFrame
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.task import PipelineTask
from pipecat.pipeline.runner import PipelineRunner
from pipecat.services.elevenlabs import ElevenLabsTTSService
from pipecat.transports.services.daily import DailyParams, DailyTransport
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():
async with aiohttp.ClientSession() as session:
(room_url, _) = await configure(session)
transport = DailyTransport(
room_url, None, "Say One Thing", DailyParams(audio_out_enabled=True))
# tts = CartesiaTTSService(
# api_key=os.getenv("CARTESIA_API_KEY"),
# voice_id="79a125e8-cd45-4c13-8a67-188112f4dd22", # British Lady
# )
tts = ElevenLabsTTSService(
aiohttp_session=session,
api_key=os.getenv("ELEVENLABS_API_KEY"),
voice_id=os.getenv("ELEVENLABS_VOICE_ID"),
model="eleven_multilingual_v2",
)
runner = PipelineRunner()
task = PipelineTask(Pipeline([tts, transport.output()]))
# Register an event handler so we can play the audio when the
# participant joins.
@transport.event_handler("on_participant_joined")
async def on_new_participant_joined(transport, participant):
participant_name = participant["info"]["userName"] or ''
await task.queue_frame(TextFrame(f"Hello there, {participant_name}!"))
await runner.run(task)
if __name__ == "__main__":
asyncio.run(main())