Hello,
I am trying to build an interruptible voice capturing system. My test scenario is as follows:
(using the node-ari package)
- Place channel into Stasis application
- Play a sound file
- Register events for
ChannelTalkingStartedandChannelTalkingFinished - Once
ChannelTalkingStartedfires, stop the playback of the sound file
This flow functions perfectly fine while running the stasis application directly on my laptop, connected to a remote asterisk server via websocket. I’ve bundled this up (mainly for testing uploading/transcribing the recorded file which lives on the asterisk server) and I ran into an issue where the sound file I’m playing would be stopped immediately.
I placed console logs in and I was indeed receiving the ChannelTalkingStarted event prior to saying anything – even if my iPhone microphone was on mute prior to the call connecting. I tried adjusting the silence threshold to 15000ms to see if something interesting was happening there, but I still encountered the problem.
Here is a code snippet demonstrating what I’m doing
let playbackId;
const playback = await channel.play({
media: 'sound:zombies',
});
channel.on('ChannelTalkingStarted', () => {
if (playbackId) {
client.playbacks.stop({
playbackId
});
}
});
Just as an experiment, I wrapped the setting of playbackId in a setTimeout:
let playbackId;
const playback = await channel.play({
media: 'sound:zombies',
});
setTimeout(() => {
playbackId = playback.id;
}, 5000);
channel.on('ChannelTalkingStarted', () => {
if (playbackId) {
client.playbacks.stop({
playbackId
});
}
});
This did indeed resolve the issue I was seeing and the prompt would continue to play continuously until I actually said something.
I guess what I want to get out of this is if anyone knows why those events are firing immediately event when my microphone is muted.
I tried adjusting the silence/talking thresholds to various levels but nothing seemed to make a difference.
Thanks!