cloudflare 宣布推出实时语音 ai 平台(cloudflare realtime agents),正式进军低延迟对话式 ai 领域。该平台依托 cloudflare 全球 330 多个节点的边缘网络,为开发者提供构建语音交互应用的完整解决方案。

新平台的核心组件包括 Realtime Agents(语音 AI 管道编排运行时)、WebRTC 音频传输支持、Workers AI 的 WebSocket 实时推理 以及 Deepgram 的语音识别/合成模型。通过这些功能,开发者可快速搭建自然流畅的语音代理应用。
下面的示例代码展示了如何创建一个继承自
RealtimeAgent
的 JavaScript 类,以进行以下操作:
创建 WebRTC 会话
管道编排(如:Deepgram STT → 自定义文本处理 Handler → ElevenLabs TTS)
支持会议参与者加入/离开的事件处理
这让开发者几乎不需管理底层基础设施,就可快速构建个性化语音代理应用。
export class MyAgent extends RealtimeAgent {constructor(ctx: DurableObjectState, env: Env) {super(ctx, env);}async init(agentId: string ,meetingId: string, authToken: string, workerUrl: string, accountId: string, apiToken: string) {// Construct your text processor for generating responses to textconst textHandler = new MyTextHandler(this.env);// Construct a Meeting object to join the RTK meetingconst transport = new RealtimeKitTransport(meetingId, authToken, [{media_kind: 'audio',stream_kind: 'microphone',},]);const { meeting } = transport;// Construct a pipeline to take in meeting audio, transcribe it using// Deepgram, and pass our generated responses through ElevenLabs to// be spoken in the meetingawait this.initPipeline([transport, new DeepgramSTT(this.env.DEEPGRAM_API_KEY), textHandler, new ElevenLabsTTS(this.env.ELEVENLABS_API_KEY), transport],agentId,workerUrl,accountId,apiToken,);// The RTK meeting object is accessible to us, so we can register handlers// on various events like participant joins/leaves, chat, etc.// This is optionalmeeting.participants.joined.on('participantJoined', (participant) => {textHandler.speak(`Participant Joined ${participant.name}`);});meeting.participants.joined.on('participantLeft', (participant) => {textHandler.speak(`Participant Left ${participant.name}`);});// Make sure to actually join the meeting after registering all handlersawait meeting.rtkMeeting.join();}async deinit() {// Add any other cleanup logic requiredawait this.deinitPipeline();}}
Cloudflare 指出,要让语音交互达到“自然对话”的体验,总延迟需低于 800 毫秒,而其分布式边缘架构正好能满足这一苛刻要求。平台同时兼容多种 AI 模型和第三方服务,支持高度可组合的语音处理管道。
目前,Cloudflare Realtime Agents 已开放 Beta 公测,开发者可免费试用并基于该平台开发新一代实时语音 AI 应用。
以上就是Cloudflare 推出实时语音 AI 平台:Realtime Agents的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/127913.html
微信扫一扫
支付宝扫一扫