Skip to content

Instantly share code, notes, and snippets.

@rktalusani
rktalusani / WebAudioOpenTok.html
Created Aug 4, 2020
Mix Microphone+Mp3 and use it as audio source for Opentok
View WebAudioOpenTok.html
<html>
<head>
<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
</head>
<body>
<audio crossOrigin="anonymous" id="mp3file" controls>
<source src="helix.mp3"/>
</audio>
<div id="layoutContainer"></div>
<button onclick="startProcess()">Let the magic begin</button>
View opentok-faceid
1. sendScreenShot (front-end js) method uses subsciber.getImgData() method to capture screenshot of the subscriber (remote participant) and post it to the server.
2. On the server we use detectFace() method to detect the facial features in this image and we get a identifier for the detected face (id1)
3. we use detectFace() again with the image we want to compare with and we get identifier for the detected face (id2)
4. we use verifyFace() method and pass id1 and id2 as the inputs. Microsoft face API compares these two faces and provides a result that includes match/mismatch as well as a score.
Reference -
1. getImgData() - https://tokbox.com/developer/sdks/js/reference/Subscriber.html#getImgData
2. Microsoft Face API - https://westus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236
View Opentok_Screenshare_WithAudio
var videoConstraints = {};
/* Width and Height optional but, framerate is a must to avoid blinking */
/* videoConstraints.width = 1280;
videoConstraints.height = 720;*/
videoConstraints.frameRate = 25;
var displayMediaStreamConstraints = {
video: videoConstraints,
audio: true
};
try {
View connect_calls_conf
app.get("/answer", function (req, res) {
console.log("uuid is:"+req.query.uuid);
var ncco = [
{
action: "conversation",
name: "conf"+req.query.uuid ,
startOnEnter: true,
record: true
}
View StereoPlaybackMonoCaptureDevice.swift
//
// DefaultAudioDevice.swift
// 4.Custom-Audio-Driver
//
// Created by Roberto Perez Cubero on 21/09/2016.
// Copyright © 2016 tokbox. All rights reserved.
//
import Foundation
import OpenTok