基础准备
需安装语音交互专用包:npm install @voltagent/voice
,该包封装了Web Speech API等底层接口。
核心配置步骤
- 开启语音功能: 在智能体配置中设置
voice: true
- 权限处理: 浏览器端需要获取麦克风权限
- 语音参数: 可调节语速、音调和语音识别敏感度
code example
const voiceAgent = new Agent({ name: "语音助手", llm: new VercelAIProvider(), model: openai("gpt-4o-mini"), voice: { recognitionLang: "zh-CN", // 中文识别 synthesisVoice: "Microsoft Yaoyao" // 中文语音 } });
typical application
- Intelligent Customer Service: 电话自动应答系统
- voice assistant: 智能家居控制中心
- Educational applications: 语言学习陪练
caveat
语音识别准确率受环境噪音影响,建议在静音环境下进行关键操作确认。浏览器兼容性方面,最新版Chrome和Edge支持最佳。
This answer comes from the articleVoltAgent: TypeScript Open Source Framework for Rapidly Building AI IntelligentsiaThe