Coder Social home page Coder Social logo

Comments (8)

myconode avatar myconode commented on August 30, 2024 1

Using @google-cloud/speech, version: 1.4.0 in a Firebase Cloud function.

We're experiencing the same error when using the longRunningRecognize method in a Firebase Cloud Function. We're also seeing Error: 14 UNAVAILABLE: TCP Read failed. Both errors appear to be originating from this module's grpc dependency. There are a few closed issues (e.g. #2438) on that project, but thought it might be helpful to mention it here as well. We have tried some of the recommendations but these have not resolved the issue.

from nodejs-speech.

stephenplusplus avatar stephenplusplus commented on August 30, 2024

Would you be able to create a reproduction gist or repo that we can run to reproduce?

from nodejs-speech.

niravpatel2008 avatar niravpatel2008 commented on August 30, 2024

Hi @stephenplusplus ,

Got some time and have created demo just to demonstrate what exactly i am using in my main application.

stt.tar.gz


Extract tar file .
1) npm install.
2) set GOOGLE_APPLICATION_CREDENTIALS env variable.
3) update port and projectid in app.js 
4) npm start or node app.js to start application.

Also i am facing intermediate issue 502 bad gateway. once you close socket from browser and wait for sometime application will crash and throw 502 or previous one error.

Try to run least 3-5 odd min speech to text. may be i have issue with reinitializing speech recognize object.

Thanks a lot in advance.

from nodejs-speech.

danoscarmike avatar danoscarmike commented on August 30, 2024

@stephenplusplus can you have another look at this please? LMK if we need to engage with grpc.

from nodejs-speech.

danoscarmike avatar danoscarmike commented on August 30, 2024

...or Cloud Functions

from nodejs-speech.

phsultan avatar phsultan commented on August 30, 2024

Hi @niravpatel2008,

Hi was wondering whether you were still experiencing this. I tried you app a few weeks ago and could reproduce your issue, but I'm failing to reproduce it again now.

I made a few modifications as I found some of the various sampling values were not consistent throughout the code, removed the unnecessary .wav package, directly use .write rather that pipe/unpipe and fixed the WebSocket connection to connect in insecure mode with localhost.

Here is the diff:

MacBook-Air-de-Philippe:node_test sultan$ diff -ru stt stt-new/
diff -ru stt/app.js stt-2/app.js
--- stt/app.js	2018-04-05 06:23:37.000000000 +0200
+++ stt-2/app.js	2018-05-24 11:40:03.000000000 +0200
@@ -1,17 +1,15 @@
 var express = require('express');
 var WebSocketServer = require('websocket').server;
-const Stream = require('stream');
 var SpeechToText = require('@google-cloud/speech');
 var path = require('path');
 var fs = require('fs');
-var wav = require('wav');
 const port = 8080;
 const projectId = "projectId";  // Need to change project id.
 
 var recognizeStreamOpt =  {
                         config: {
                           encoding: "LINEAR16",
-                          sampleRateHertz: "48000",
+                          sampleRateHertz: "44100",
                           languageCode: "en-US",
                           profanity_filter: true,
                         },
@@ -34,30 +32,27 @@
         console.log("request")
         var connection = request.accept(null, request.origin);
         var speech_to_text = new SpeechToText.SpeechClient({projectId: projectId});
-        var bufferStream = new wav.Writer();
+        var recognize = null;
 
         var startRecognize = function(){
-        var recognize = speech_to_text.streamingRecognize(recognizeStreamOpt)
-        .on('error', (e)=>{
+          recognize = speech_to_text.streamingRecognize(recognizeStreamOpt)
+          .on('error', (e)=>{
                 if (typeof e["code"] != "undefined" && e["code"] == 11)
                 {
                         console.log("error",e);
-                        bufferStream.unpipe(recognize);
                         startRecognize();
                         //connection.sendUTF(JSON.stringify(e))
                 }
 				       })
-        .on('data', data => {
+          .on('data', data => {
                 console.log("data",data);
                 connection.sendUTF(JSON.stringify(data))
-        });
-
-        bufferStream.pipe(recognize);
+          });
         }
 
         connection.on('message', function(message) {
                 if (message.type === 'binary') {
-                        bufferStream.write(Buffer.from(message.binaryData));
+                        recognize.write(Buffer.from(message.binaryData));
                 }
                 else
                 {
@@ -67,4 +62,4 @@
         });
 
         connection.sendUTF("");
-});
\ No newline at end of file
+});
Only in stt-2: node_modules
Only in stt-2: package-lock.json
diff -ru stt/public/main.js stt-2/public/main.js
--- stt/public/main.js	2018-03-22 07:50:51.000000000 +0100
+++ stt-2/public/main.js	2018-05-23 11:27:22.000000000 +0200
@@ -135,7 +135,8 @@
   rafCallback();
 
   // per https://g.co/cloud/speech/reference/rest/v1beta1/RecognitionConfig
-  const SAMPLE_RATE = 16000;
+  // Not sure those values are actually used, but anyway
+  const SAMPLE_RATE = 44100;
   const SAMPLE_SIZE = 16;
 
   var playButton = document.getElementById('playbutton');
@@ -191,7 +192,7 @@
 
     function newWebsocket() {
       var websocketPromise = new Promise(function(resolve, reject) {
-        var socket = new WebSocket('wss://' + location.host);
+        var socket = new WebSocket('ws://' + location.host);
         socket.addEventListener('open', resolve);
         socket.addEventListener('error', reject);
       });

Here is the updated version I worked with :
stt-2.tar.gz

Great PoC by the way ;-)

from nodejs-speech.

stephenplusplus avatar stephenplusplus commented on August 30, 2024

@niravpatel2008 please let us know if you are still having this issue. Thanks!

from nodejs-speech.

myconode avatar myconode commented on August 30, 2024

@stephenplusplus @danoscarmike Was there a fix released in one of the google client libs (this one or a dependency), or was this fixed behind the scenes? For what its worth we've noticed a significant improvement in latency since 6/20 for our Firebase Cloud function using speech client's longRunningRecognize (50% improvement in latency but its still not ideal). Happy to share some more details if helpful.

from nodejs-speech.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.