Navigate to the backend directory and install dependencies:
cd mbz-voice-sdk/backend
pip install -r requirements.txt
# Create a .env file with your Gemini API key
echo "GEMINI_API_KEY=your_api_key_here" > .env
# Start the server
uvicorn main:app --reload
<!DOCTYPE html>
<html>
<head>
<title>MBZ Voice SDK Demo</title>
</head>
<body>
<button id="start-btn">Start Listening</button>
<div id="response"></div>
<script type="module">
import { MBZVoiceAgent } from "./mbz-voice-sdk.js"
const agent = new MBZVoiceAgent({
apiUrl: "http://localhost:8000/ask",
lang: "en-US",
speak: true
})
document.getElementById("start-btn").onclick = () => {
agent.listen()
}
</script>
</body>
</html>
// Add event handlers
agent.onTranscript((text) => {
console.log("User said:", text)
document.getElementById("response").textContent = "You: " + text
})
agent.onResponse((reply) => {
console.log("AI replied:", reply)
document.getElementById("response").textContent += "\nAI: " + reply
})