Comments (8)
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.
Would you be able to create a reproduction gist or repo that we can run to reproduce?
from nodejs-speech.
Hi @stephenplusplus ,
Got some time and have created demo just to demonstrate what exactly i am using in my main application.
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.
@stephenplusplus can you have another look at this please? LMK if we need to engage with grpc.
from nodejs-speech.
...or Cloud Functions
from nodejs-speech.
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.
@niravpatel2008 please let us know if you are still having this issue. Thanks!
from nodejs-speech.
@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)
- BetaFeatures: should run speech diarization on a GCS file failed
- BetaFeatures: should run multi channel transcription on a local file failed
- BetaFeatures: should run multi channel transcription on GCS file failed
- BetaFeatures: should transcribe multi-language on a local file failed
- BetaFeatures: should run word Level Confience on a local file failed
- Speech-to-Text export to Cloud Storage : should export transcriptions failed
- Speech-to-Text export to Cloud Storage : "after all" hook: should delete the bucket used for the test for "should export transcriptions" failed
- modelAdaptation: should run modelAdaptation failed
- modelAdaptation: "after all" hook for "should run modelAdaptation" failed
- multiRegion: should run multiRegion failed
- profanityFilter: should run profanityFilter failed
- Quickstart: should run quickstart failed
- Recognize: "before all" hook for "should run sync recognize" failed
- Recognize: "after all" hook for "should run speech diarization on a local file" failed
- Recognize v1p1beta1: should run sync recognize with metadata failed
- transcribe context classes: should detect transcriptions failed HOT 1
- Warning: a recent release failed
- SpeechClient system test v1: calls longRunningRecognize failed HOT 1
- SpeechClient system test v1p1beta1: calls recognize failed HOT 1
- SpeechClient TypeScript system test v1: calls longRunningRecognize failed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-speech.