Basic Preparation
A special package for voice interaction needs to be installed:npm install @voltagent/voiceThis package encapsulates the underlying interfaces such as the Web Speech API.
Core Configuration Steps
- Turn on the voice function: Set in the smartbody configuration
voice: true - privilege handling: Browser-side microphone access required
- speech parameter:: Adjustable speech rate, pitch and speech recognition sensitivity
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:: Automatic telephone answering system
- voice assistant: Smart Home Control Center
- Educational applications: Language Learning Accompaniment
caveat
Speech recognition accuracy is affected by ambient noise, so it is recommended to confirm key operations in a silent environment. For browser compatibility, the latest versions of Chrome and Edge are best supported.
This answer comes from the articleVoltAgent: TypeScript Open Source Framework for Rapidly Building AI IntelligentsiaThe
































