Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var async = require('async');
var fs = require('fs');
var path = require('path');
var grpc = require('grpc');
var googleProtoFiles = require('google-proto-files');
var googleAuth = require('google-auto-auth');
var Transform = require('stream').Transform;
// [START proto]
var PROTO_ROOT_DIR = googleProtoFiles('..');
var protoDescriptor = grpc.load({
root: PROTO_ROOT_DIR,
file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1beta1)
}, 'proto', {
binaryAsBase64: true,
convertFieldsToCamelCase: true
});
var speechProto = protoDescriptor.google.cloud.speech.v1beta1;
// [END proto]
// [START authenticating]
function getSpeechService (host, callback) {
var googleAuthClient = googleAuth({
scopes: [
'https://www.googleapis.com/auth/cloud-platform'
]
});
googleAuthClient.getAuthClient(function (err, authClient) {
var fs = require('fs');
var cursor = ansi(process.stdout);
//Lets require/import the HTTP module
var http = require('http');
var url = require("url");
//Lets define a port we want to listen to
const PORT=9950;
// [START proto]
var PROTO_ROOT_DIR = googleProtoFiles('..');
var mic = null;
var protoDescriptor = grpc.load({
root: PROTO_ROOT_DIR,
file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1beta1)
}, 'proto', {
binaryAsBase64: true,
convertFieldsToCamelCase: true
});
var speechProto = protoDescriptor.google.cloud.speech.v1beta1;
// [END proto]
//We need a function which handles requests and send response
function handleRequest(request, response){
var method = url.parse(request.url).query;
if (method=="startListening"){
//var reqestCommand = "GOOGLE SPEACH DEAMON : Start Recognition";
var async = require('async');
var fs = require('fs');
var path = require('path');
var grpc = require('grpc');
var googleProtoFiles = require('google-proto-files');
var googleAuth = require('google-auto-auth');
var Transform = require('stream').Transform;
var record = require('node-record-lpcm16');
const config = require('../config');
var PROTO_ROOT_DIR = googleProtoFiles('..');
var protoDescriptor = grpc.load(
{
root: PROTO_ROOT_DIR,
file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1),
},
'proto',
{
binaryAsBase64: true,
convertFieldsToCamelCase: true,
}
);
var speechProto = protoDescriptor.google.cloud.speech.v1;
var isListening = false;
var stopTimer = null;
console.log('STARTING STREAM.js');
function getSpeechService(callback) {
var googleAuthClient = googleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
getSpeechProto: () => {
var PROTO_ROOT_DIR = googleProtoFiles('..');
var protoDescriptor = grpc.load({
root: PROTO_ROOT_DIR,
file: path.relative(PROTO_ROOT_DIR, googleProtoFiles.speech.v1beta1)
}, 'proto', {
binaryAsBase64: true,
convertFieldsToCamelCase: true
});
return protoDescriptor.google.cloud.speech.v1beta1.Speech;
},