medooze / media-server-node

WebRTC Media Server for Node.js
MIT License
802 stars 119 forks source link

Active speaker detection event not triggering #144

Closed pradeep538 closed 4 years ago

pradeep538 commented 4 years ago

hi @murillo128 i have added below code to detect voice activity

`var room = {} room.activeSpeaker = MediaServer.createActiveSpeakerDetector(); //adding each client incoming track try{ await room.activeSpeaker.addSpeaker( client.incomingStream && client.incomingStream.getAudioTracks() );

      }catch(voaError){
        console.log("VOD_ERROR:",voaError)
      }

room.activeSpeaker.on("activespeakerchanged", (track) => { console.log("VOICE_ACTIVITY_CHANGED", track); }); `

am getting below error VOD_ERROR: TypeError: Cannot read property 'values' of undefined at ActiveSpeakerDetector.addSpeaker (/home/pradi/node_modules/medooze-media-server/lib/ActiveSpeakerDetector.js:99:34) at /home/pradi/dist/lib/conferenceHandler.js:76:46 at Generator.next () at /home/pradidist/lib/conferenceHandler.js:8:71 at new Promise () at __awaiter (/home/pradi/dist/lib/conferenceHandler.js:4:12) at Object.exports.createTransportObject (/home/pradi/dist/lib/conferenceHandler.js:43:56) at /home/pradi/dist/lib/conferenceHandler.js:41:26 at Generator.next () at /home/pradi/dist/lib/conferenceHandler.js:8:71

pradeep538 commented 4 years ago

Sorry for trobling, as i have changed the getAudioTracks() to await room.activeSpeaker.addSpeaker( client.incomingStream && client.incomingStream.getAudioTracks()[0] );

It worked perfectly Hence it is working fine am closing this issue. Thank You.