@urth/metatell-sdk/voice exposes the current user's microphone level and
speaking state. To observe other users' speaking state, use
Remote Users.
getLocalLevel() returns the latest microphone input level for the current
user. Poll it from your render loop to drive a mic meter.
import { getLocalLevel } from "@urth/metatell-sdk/voice";
function tick() {
const level = getLocalLevel(); // number
meter.style.width = `${Math.min(level, 1) * 100}%`;
requestAnimationFrame(tick);
}
The value starts at 0 until the host begins reporting levels.
onSpeaking() notifies you when the local speaking state changes. It returns an
Unsubscribe function; call it on teardown.
import { onSpeaking } from "@urth/metatell-sdk/voice";
const off = onSpeaking((event) => {
console.log(event.speaking, event.level);
});
interface SpeakingEvent {
sessionId: string;
speaking: boolean;
level: number;
}