Skip to content

Instantly share code, notes, and snippets.

@rktalusani
rktalusani / gist:aee2b673c89d26a0535eb18bd1bb2aa2
Created October 26, 2023 04:59
Increase the volume of an audio buffer
public byte[] increaseVolume(byte[] audioBuffer) {
for (int i = 0; i < audioBuffer.length; i += 2) {
// Convert 16-bit little-endian PCM samples to a short
short sample = (short)((audioBuffer[i] & 0xFF) | (audioBuffer[i + 1] << 8));
// Increase the volume by 10%
sample = (short)(sample * 1.1);
// Clip the value to stay within the 16-bit range
if (sample > Short.MAX_VALUE) {
const express = require('express')
var bodyParser = require('body-parser')
const uuid = require("uuid")
const jwt = require("jsonwebtoken")
const request = require('request');
const fs = require('fs')
const app = express()
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
const app_id="39dc9665-f65e-4764-92d3-715aa98b3f55";
#!/bin/bash
generate_podfile(){
echo "platform :ios, '12.0'
install! 'cocoapods', integrate_targets: false
use_frameworks!
pod 'OTXCFramework', '$1'
" > Podfile
location /proxy/ {
if ($request_method = OPTIONS ) {
add_header Allow "POST, GET, OPTIONS";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Allow-Origin "*";
return 200;
}
resolver 8.8.8.8 ipv6=off;
rewrite /proxy/(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^\/?\n]+)(.+) $2 break;
//
// 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
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
}
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 {
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
@rktalusani
rktalusani / WebAudioOpenTok.html
Created August 4, 2020 14:21
Mix Microphone+Mp3 and use it as audio source for Opentok
<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>