Skip to content

Instantly share code, notes, and snippets.

View buddyeorl's full-sized avatar

Alex Lizarraga buddyeorl

View GitHub Profile
const ds = require('deepspeech-tflite');
const fs = require('fs');
let model = new ds.Model('./pathTodeepspeech.tflite');
model.enableExternalScorer('./pathTodeepspeech.scorer');
const deepSpeech = async (req, res, next) => {
//if no file was received
if (!req.file) {
res.send({ message: 'No audio file has been received' });
return

API calls to

https://deep-talk.azurewebsites.net/api/v1/getVoice

POST requests accepts 16kHZ mono 16bits WAV audio files in multipart form data,the field name should be 'audio'

sample responses:

No audio file:

import React, {useRef} from 'react';
const AudioGraph = ({dataArray})=>{
const canvasRef = useRef();
//this function updates the canvas reference with the current sound frequencies
const draw = () => {
//canvasRef is a ref created with useRef hook
canvasRef.current.getContext('2d').fillStyle = 'rgb(255, 255, 255,0.5)';
canvasRef.current.getContext('2d').clearRect(0, 0, window.innerWidth, 100);
@buddyeorl
buddyeorl / VAD.js
Last active November 1, 2020 03:36
How to implement Voice Activity Detection using javascript
//new audiocontext
let audioCtx = new (window.AudioContext || window.webkitAudioContext)();
//analyzer for the audio context
let analyser =audioCtx.createAnalyser();
//request microphone access
navigator.mediaDevices.getUserMedia({ audio: true, video: false })
.then(async (stream) => {
//analize sound waves
//stream source
import React from 'react';
import ActivateOnClick from '../PathToActivateOnClick;
//CodeGist props:
//url:string //<-- represents the Github gist url
//CodeGist accept a children component as a prop, so you can wrap a label or any component you want to render before
// the Gist
const Example=()=>{
return(
<React.Fragment>
import React from 'react';
import CodeGist from '../PathToCodeGist;
//CodeGist props:
//url:string //<-- represents the Github gist url
//CodeGist accept a children component as a prop, so you can wrap a label or any component you want to render before
// the Gist
const Example=()=>{
return(
<React.Fragment>
//Im a comment
//me too
const imAFunctionExample=()=>{
console.log("Hello World");
}
imAFunctionExample();
import React from 'react';
import ChattyForm from '../PathToChattyForm';
//import icons
import FingerPrintIcon from '../PathToFingerPrintIcon'
import AlternateEmailIcon from '../PathToAlternateEmailIcon'
import CommentIcon from '../PathToCommentIcon'
//ChattyForm props:
//inputs: Array[{},{},{},...,{},{},[string],[string]]
import React from 'react';
import ChatButton from '../PathToChatButton;
//ChatButton props:
//label:string
//shadow:boolean <= shows the activity indicator
//direction:enum string <= options:left, right,left-reversed,right-reveresed
//onClick:function <= custom function to handle on click events.
//send: boolean <= if true, the shape of the button change to rectangle and color green
// if (send === true), ChatButton MUST be wrapped by a position relative parent