SIGN UP

Tag: microphone

Web SDK: Microphone Activity Visualization

Mic Activity

If you are embedding VoIP functionality into your web application then it's a good idea to show end user some feedback from the system about his audio settings, especially related to his microphone / audio recording device. Combining the power of WebRTC , HTML5 and Web we can visualize audio stream coming from microphone after user allowed access to the device. Since version 3.6.294 of the Web SDK,  developers can access to MediaStream object - it's available as stream property of MicAccessResult event, or as successCallback function argument which itself is an argument of the following functions attachRecordingDevice, useAudioSource, useVideoSource, setVideoSettings.

read more >>>

Microphone testing service

Headset

Many Skype users are familiar with its microphone testing service (echo123). When you call the testing service it asks you to say something and records the stream, then it plays it back and if you hear your voice it means that your audio recording device is configured correctly. You can implement similar scenario for your VoxImplant application by using the following VoxEngine scenario:

require(Modules.Recorder);

let fileURL;
let call;

VoxEngine.addEventListener(AppEvents.CallAlerting, (e) => {
  call = e.call;
  e.call.answer();
  e.call.addEventListener(CallEvents.Connected, (e) => {
    call.say('Hello, welcome to VoxImplant testing service.' +
      'After the beep please record your message,' +
      'afterwards your message will be played back to you.',
      Language.UK_ENGLISH_FEMALE);
    call.addEventListener(CallEvents.PlaybackFinished, handleIntroPlayed);

  });
  e.call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);
});

function handleIntroPlayed(e) {
  call.removeEventListener(CallEvents.PlaybackFinished, handleIntroPlayed);
  call.startPlayback('http://cdn.zingaya.com/sounds/beep-1.mp3');
  call.addEventListener(CallEvents.PlaybackFinished, handleRecordStart);
}

function handleRecordStart(e) {
  call.removeEventListener(CallEvents.PlaybackFinished, handleRecordStart);
  let rec = VoxEngine.createRecorder();
  rec.addEventListener(RecorderEvents.Started, handleRecordingStarted);
  rec.addEventListener(RecorderEvents.Stopped, handleRecordingStopped);
  e.call.sendMediaTo(rec);
  setTimeout(() => {
    rec.stop();
  }, 6000);
}

function handleRecordingStarted(e) {
  fileURL = e.url;
}

function handleRecordingStopped(e) {
  call.startPlayback(fileURL);
  call.addEventListener(CallEvents.PlaybackFinished, (e) => {
    setTimeout(handleRecordPlayed, 1000);
  });
}

function handleRecordPlayed() {
  call.say('If you were able to hear your own voice, ' +
    'then you have configured your audio recording device correctly.' +
    'If you hear this message but not your own voice then you need to configure' +
    ' your audio recording device. Goodbye.', 
    Language.UK_ENGLISH_FEMALE);
  call.addEventListener(CallEvents.PlaybackFinished, (e) => {
    VoxEngine.terminate();
  });
}
read more >>>

Microphone activity event

Mic Activity

Measuring microphone activity can be useful in many cases. For example, in case of audio conference it lets developer highlight conference participant who is talking at the moment, or another useful scenario example - measuring call participant's speech length. Now VoxImplant developers can detect microphone activity at VoxEngine scenarios level, we've implement new method for Call class - handleMicStatus , set handle to true and then use new CallEvents.MicStatusChange event to receive the information about microphone activity. Please check the usage example below:

// Inbound call processing
VoxEngine.addEventListener(AppEvents.CallAlerting, e => {
  const call = e.call;
  // Enable mic status tracking
  call.handleMicStatus(true);
  call.addEventListener(CallEvents.Connected, e => {
    Logger.write("Call connected");
  });
  // Add event listener for mic activity events
  call.addEventListener(CallEvents.MicStatusChange, e => {
    // Write mic activity info into log file
    Logger.write("Mic active: " + e.active);
  });
  call.answer();
});
read more >>>
Get your free developer account or talk with our sales team to learn more about Voximplant solutions
SIGN UP
Contact sales

Please complete this field.

Please complete this field.

Please complete this field.

Choose the solution

Please complete this field.

Please complete this field.