Skip to content

Instantly share code, notes, and snippets.


haruiz/stt.js Secret

Last active March 27, 2017 08:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
const util = require("util");
const Guid = require("guid");
const querystring = require('querystring');
const path = require("path");
const bluebird = require("bluebird");
const axios = require("axios");
const fs = bluebird.promisifyAll(require("fs"));
const {getToken} = require("./common");
const stt = async(BING_SPEECH_API_KEY, audioAsBInary)=>{
var authToken = await getToken(BING_SPEECH_API_KEY), params = "";
/* URI Params. Refer to the README file for more information. */
var params = {
"appid": "D4D52672-91D7-4C74-8AD8-42B1D98141A5",
"locale" :"es-ES",
"device.os": "wp7",
"format": "json",
"requestid" : Guid.raw()
var uri = ""+querystring.stringify(params);
var config = {
"Authorization" : "Bearer " +,
"content-type" : "audio/wav; codec=\"audio/pcm\"; samplerate=16000"
/*var audioAsBInary = await fs.readFileAsync("./speak.wav"); */ return await,audioAsBInary,config ); //just making a request
module.exports = stt;//we need to export the function, because the idea is invoke the function from the index file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment