mbz-voice-sdk
Version:
🎙️ MBZ Voice SDK: Easily add voice recognition, Gemini-based AI replies, and TTS to any web app.
28 lines (22 loc) • 654 B
JavaScript
import { MBZVoiceAgent } from './mbz-voice-sdk.js'; // ✅ Works in browser
const responseBox = document.getElementById("response");
const agent = new MBZVoiceAgent({
apiUrl: 'http://localhost:8000/ask',
lang: 'en-US',
speak: true
});
agent.onTranscript((text) => {
console.log("You:", text);
responseBox.textContent = "You: " + text;
});
agent.onResponse((reply) => {
console.log("AI:", reply);
responseBox.textContent += "\nAI: " + reply;
});
document.getElementById("start-btn").onclick = () => {
try {
agent.listen();
} catch (e) {
responseBox.textContent = "❌ Error: " + e.message;
}
};