Install the Micdrop Client in the Browser
Install Micdrop client package for browser-based voice conversations.
Package Installation
npm install @micdrop/webThatβs it! No additional configuration or dependencies needed.
On a phone, install @micdrop/react-native
instead. Both packages are built on @micdrop/client, which comes along on its
own and which you never install directly.
Vite Plugin
We strongly recommend this plugin for any app built with Vite that uses Silero VAD or turn detection. Without it, the model and the ONNX runtime are fetched from jsDelivr and unpkg when a call starts, and a CDN outage, a company firewall or an ad blocker is then enough to keep voice detection from starting.
import { micdrop } from '@micdrop/web/vite'import { defineConfig } from 'vite'
export default defineConfig({ plugins: [micdrop()],})The plugin ships the Silero model with your app, and Vite emits the
WebAssembly files of the ONNX runtime next to your other assets, from the very
version you installed. Your code stays the same: keep importing
@micdrop/web/silero and @micdrop/smart-turn/web, the plugin configures
them. It works in development and in production builds, whatever your base.
Silero only runs on WebAssembly, so the plugin picks the WebAssembly build of
the ONNX runtime, about 14 MB where the full build weighs 28 MB.
Turn detection runs on the graphics card when
the browser offers it, so the full build is kept whenever @micdrop/smart-turn
is installed. Every import of the runtime gets the same build, so your app
never loads two of them. To choose yourself, for instance when your own code
runs an ONNX model on WebGPU, pass micdrop({ webgpu: true }).
With another bundler, serve the files from your own domain and point Micdrop at
them with setSileroOptions, as shown in Silero VAD.
Framework Integration
Vanilla JavaScript/TypeScript
import { Micdrop } from '@micdrop/web'
// Start a voice conversationawait Micdrop.start({ url: 'ws://localhost:8081', vad: ['volume', 'silero'],})
// Listen for state changesMicdrop.on('StateChange', (state) => { console.log('Listening:', state.isListening) console.log('Processing:', state.isProcessing) console.log('Assistant speaking:', state.isAssistantSpeaking)})
// Stop the conversationawait Micdrop.stop()React
For React applications, also install the React hooks package:
npm install @micdrop/reactimport { Micdrop } from '@micdrop/web'import { useMicdropState } from '@micdrop/react'
function VoiceChat() { const state = useMicdropState() const handleStart = () => Micdrop.start({ url: 'ws://localhost:8081/' }) const handleStop = () => Micdrop.stop()
return ( <div> <button onClick={handleStart}>Start</button> <button onClick={handleStop}>Stop</button> {state.isListening && <p>π€ Listening...</p>} {state.isProcessing && <p>π€ Processing...</p>} {state.isAssistantSpeaking && <p>π Assistant speaking...</p>} </div> )}Learn more about Micdrop React hooks.
Vue.js
<template> <div> <button @click="startCall">Start Call</button> <button @click="stopCall">Stop Call</button> </div></template>
<script> import { Micdrop } from '@micdrop/web'
export default { methods: { async startCall() { await Micdrop.start({ url: 'ws://localhost:8081/', }) }, async stopCall() { await Micdrop.stop() }, }, }</script>Angular
import { Component } from '@angular/core'import { Micdrop } from '@micdrop/web'
@Component({ selector: 'app-voice-chat', template: ` <button (click)="startCall()">Start Call</button> <button (click)="stopCall()">Stop Call</button> `,})export class VoiceChatComponent { async startCall() { await Micdrop.start({ url: 'ws://localhost:8081/', }) }
async stopCall() { await Micdrop.stop() }}CDN Usage
For quick prototyping or simple HTML pages:
<script type="module"> import { Micdrop } from 'https://unpkg.com/@micdrop/web@latest/dist/index.js'
await Micdrop.start({ url: 'ws://localhost:8081/', })</script>