微信扫码
添加专属顾问
我要投稿
pipecat 是用于构建语音(和多模态)对话代理的框架。诸如私人教练、会议助理、儿童讲故事玩具、客户支持机器人、摄入流程和尖刻的社交伙伴。
您可以开始在本地计算机上运行 Pipecat,然后在准备就绪后将代理进程移动到云中。您还可以添加?电话号码、?️图像输出、?视频输入、使用不同的 LLMs,等等。
# install the modulepip install pipecat-ai# set up an .env file with API keyscp dot-env.template .env
默认情况下,为了最小化依赖关系,只有基本的框架功能可用。某些第三方 AI 服务需要额外的依赖项,您可以使用这些依赖项进行安装:
pip install "pipecat-ai[option,...]"
您的项目可能需要也可能不需要这些,因此它们作为可选要求提供。下面是一个列表:
AI services: anthropic, azure, fal, moondream, openai, playht, silero, whisper
Transports: local, websocket, daily
基础 — 相互构建的小片段,一次引入一个或两个概念
示例应用程序 — 可用作开发起点的完整应用程序
这是一个非常基本的 Pipecat 机器人,当用户加入实时会话时,它会向他们打招呼。我们将使用 Daily 进行实时媒体传输,并使用 ElevenLabs 进行文本转语音。
#app.pyimport asyncioimport aiohttpfrom pipecat.frames.frames import EndFrame, TextFramefrom pipecat.pipeline.pipeline import Pipelinefrom pipecat.pipeline.task import PipelineTaskfrom pipecat.pipeline.runner import PipelineRunnerfrom pipecat.services.elevenlabs import ElevenLabsTTSServicefrom pipecat.transports.services.daily import DailyParams, DailyTransportasync def main():async with aiohttp.ClientSession() as session:# Use Daily as a real-time media transport (WebRTC)transport = DailyTransport(room_url=...,token=...,"Bot Name",DailyParams(audio_out_enabled=True))# Use Eleven Labs for Text-to-Speechtts = ElevenLabsTTSService(aiohttp_session=session,api_key=...,voice_id=...,)# Simple pipeline that will process text to speech and output the resultpipeline = Pipeline([tts, transport.output()])# Create Pipecat processor that can run one or more pipelines tasksrunner = PipelineRunner()# Assign the task callable to run the pipelinetask = PipelineTask(pipeline)# Register an event handler to play audio when a# participant joins the transport WebRTC sessionasync def on_new_participant_joined(transport, participant):participant_name = participant["info"]["userName"] or ''# Queue a TextFrame that will get spoken by the TTS service (Eleven Labs)await task.queue_frames([TextFrame(f"Hello there, {participant_name}!"), EndFrame()])# Run the pipeline taskawait runner.run(task)if __name__ == "__main__":asyncio.run(main())
运行它:
python app.py
Daily 提供预构建的 WebRTC 用户界面。在应用程序运行时,您可以访问 https://<yourdomain>.daily.co/<room_url> 并听机器人打招呼!
WebSocket 非常适合服务器到服务器的通信或初始开发。但对于生产用途,您需要客户端-服务器音频才能使用专为实时媒体传输而设计的协议。(有关 WebSockets 和 WebRTC 之间区别的解释,请参阅这篇文章。
快速启动和运行WebRTC的一种方法是注册一个Daily开发者帐户。Daily 为您提供用于音频(和视频)路由的 SDK 和全球基础设施。每个帐户每月可免费获得 10,000 分钟的音频/视频/转录时间。
在此处注册并在开发者仪表板中创建房间。
语音活动检测 — 对于了解用户何时完成与机器人的通话非常重要。如果您不使用按压通话,并希望 Pipecat 检测用户何时完成通话,VAD 是自然感觉对话的重要组成部分。
Pipecast 在使用 WebRTC 传输层时默认使用 WebRTC VAD。或者,您可以使用Silero VAD来提高精度,但代价是CPU使用率更高。
pip install pipecat-ai[silero]
首次使用 Silero 运行机器人时,启动可能需要一段时间,同时在后台下载和缓存模型。您可以在控制台中查看此操作的进度。
请注意,在按照以下说明操作之前,您可能需要设置虚拟环境。例如,您可能需要从存储库的根目录运行以下命令:
python3 -m venv venvsource venv/bin/activate
在此存储库的根目录下,运行以下命令:
pip install -r dev-requirements.txt -r {env}-requirements.txtpython -m build这将生成包。若要在本地使用包(例如运行示例文件),请运行
pip install --editable .
从根目录中,运行:
pytest --doctest-modules --ignore-glob="*to_be_updated*" src tests
https://github.com/pipecat-ai/pipecat
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2025-08-21
2025-08-20
2025-09-07
2025-08-21
2025-08-19
2025-08-05
2025-09-16
2025-08-20
2025-10-02
2025-09-08
2025-10-29
2025-10-29
2025-10-29
2025-10-28
2025-10-28
2025-10-28
2025-10-27
2025-10-27