🎤Micdrop

Carry a Voice Call over WebSocket, WebRTC or a Phone Line

A transport carries a call between MicdropServer and whatever is at the other end: a browser, a mobile app, or a phone. The server only talks to its transport, so the agent, the speech to text and the text to speech stay the same whichever one you pick.

TransportFar endPackageTurns detected by
WebSocketBrowser, React Native app@micdrop/server, the defaultThe client, or the server
WebRTCBrowser, React Native app@micdrop/webrtcThe client, or the server
Twilio, Vonage, Telnyx, PlivoPhone@micdrop/telephonyThe server

WebSocket, the default

Handing a socket to MicdropServer uses the WebSocket transport, which is how every Micdrop server has always worked:

wss.on('connection', (socket) => {
new MicdropServer(socket, config)
})

It needs nothing beyond the server you already run, and its frames are readable in the network tab of the browser. The protocol page lists every one of them. Passing the transport yourself does the same thing:

import { MicdropServer, WebSocketTransport } from '@micdrop/server'
new MicdropServer(new WebSocketTransport(socket), config)

WebRTC, for weak networks

WebRTC sends the audio over UDP, where a lost packet is skipped rather than resent. A user on a train or on a crowded wifi hears a voice that keeps its pace instead of one that stutters, and the browser cancels the echo of a WebRTC track better than that of audio it plays itself. It costs a signaling route and open UDP ports on the server, and a TURN server for the users behind strict firewalls.

Phone lines

A telephony transport answers calls to a phone number through the media stream WebSocket of the provider. The caller speaks into a phone, so there is no client to install, and no client to detect the turns either: the server detects them itself.

Who detects the turns

Over a WebSocket or WebRTC, the client runs its voice activity detection by default and tells the server when the user starts and stops speaking. It sends audio only while the user speaks, and a turn detector in the browser can close the turn sooner.

The server can take that role, with vad in its config. It then finds the turns in the audio it receives, the client streams its whole microphone and follows. That is the only choice on a phone line, and an option elsewhere for a client that cannot run a VAD, or to keep every decision on the server.

import { MicdropServer } from '@micdrop/server'
import '@micdrop/vad/node'
new MicdropServer(transport, {
...config,
vad: 'silero',
})

Detect the turns on the server covers the options.

Writing a transport

A transport is a class that turns what it receives into user audio at 16 kHz and turn commands, and turns the messages and the voice of the server into whatever its far end reads. Write a custom transport shows the contract, with an in-memory transport as an example.