Expand description
Voice Channels: hear what members say and speak into the call. A bot may be in as many
calls at once as it likes, each its own VoiceCall.
Audio is 48 kHz PCM (i16), mono unless a name says stereo. What you hear arrives one 20 ms
mono frame per speaker at a time; what you say, mono or stereo, is queued and sent in real
time, so a long clip plays at its own pace.
let listener = bot.clone();
tokio::spawn(async move { listener.run(|_, _| async {}).await }); // how the call finds its members
let call = bot.channel(channel_id).join_voice().await?;
call.say(&vector_sdk::voice::tone(440.0, 1000)); // a second of A4
while let Some(speech) = call.listen().await {
println!("{:?} said {} samples", speech.npub, speech.pcm.len());
}Structs§
- InCall
- A member in a voice Channel’s call, as every client lists them.
- Speech
- One 20 ms frame someone said.
- Transcriber
- Speech to text with Whisper. Load a ggml model
once, then transcribe what
Utterancesgathers. - Utterance
- What one speaker said from when they began until they paused.
- Utterances
- Turns the frames a call hears into
Utterances: each speaker’s words, cut at their pauses. Feed it everySpeechfromVoiceCall::listen. - Voice
Call - One voice Channel’s call this bot is in.
leavewhen done; dropping it leaves the call running. - Voice
Peer - Voice
State
Constants§
- DEFAULT_
KBPS - The Opus bitrate a call starts at, mono or stereo, in kbit/s. A mesh uploads it once per peer.
- FRAME
- Samples in one 20 ms frame, per channel: stereo has twice as many, interleaved.
- MAX_
KBPS - The highest bitrate a call accepts, in kbit/s: about 800 bytes a frame, under [
MAX_PACKET] with room for a burst. - MIN_
KBPS - The lowest bitrate a call accepts, in kbit/s.
- SAMPLE_
RATE - Samples per second of everything heard and said.
Functions§
- decode_
stereo_ with_ ffmpeg decode_with_ffmpegas 48 kHz stereo, interleaved, forVoiceCall::say_stereo. A mono file comes out the same on both sides.- decode_
with_ ffmpeg - Read any audio file
ffmpegcan, as 48 kHz mono PCM. Needsffmpegon the PATH. Only local files: a URL would reach the network outside the bot’s transport. - level
- How loud
pcmis, 0 to 1. - tone
- A sine tone, for tests and chimes:
hzforms, at a moderate level.