SIGN UP

Microphone testing service

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();
  });
}
Tags:web sdk
B6A24216-9891-45D1-9D1D-E7359CEB8282 Created with sketchtool.

Answers(0)

Add your comment

Please complete this field.

Recommend

Get your free developer account or talk with our sales team to learn more about Voximplant solutions
SIGN UP