{"action":"created","issue":{"url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/163","repository_url":"https://api.github.com/repos/googleapis/nodejs-speech","labels_url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/163/comments","events_url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/163/events","html_url":"https://github.com/googleapis/nodejs-speech/issues/163","id":358122347,"node_id":"MDU6SXNzdWUzNTgxMjIzNDc=","number":163,"title":"Google speech api IsFinal Response is too slow","user":{"login":"JustinBeckwith","id":534619,"node_id":"MDQ6VXNlcjUzNDYxOQ==","avatar_url":"https://avatars2.githubusercontent.com/u/534619?v=4","gravatar_id":"","url":"https://api.github.com/users/JustinBeckwith","html_url":"https://github.com/JustinBeckwith","followers_url":"https://api.github.com/users/JustinBeckwith/followers","following_url":"https://api.github.com/users/JustinBeckwith/following{/other_user}","gists_url":"https://api.github.com/users/JustinBeckwith/gists{/gist_id}","starred_url":"https://api.github.com/users/JustinBeckwith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustinBeckwith/subscriptions","organizations_url":"https://api.github.com/users/JustinBeckwith/orgs","repos_url":"https://api.github.com/users/JustinBeckwith/repos","events_url":"https://api.github.com/users/JustinBeckwith/events{/privacy}","received_events_url":"https://api.github.com/users/JustinBeckwith/received_events","type":"User","site_admin":false},"labels":[{"id":655716370,"node_id":"MDU6TGFiZWw2NTU3MTYzNzA=","url":"https://api.github.com/repos/googleapis/nodejs-speech/labels/type:%20question","name":"type: question","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-07T15:54:01Z","updated_at":"2018-09-21T06:55:14Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"_From @wassizafar786 on September 7, 2018 5:39_\r\n\r\nHi This is me Wassi \r\n\r\nI am facing a issue like i am using websocket to send stream to node server and receive result but google cloud speech api send me back isFinal result is very slow \r\nBelow is my client side code\r\n\r\n```js\r\n  this.speechServerClient = new BinaryClient(environment.speechServerUrl)\r\n            .on('error', this.onerror.bind(this))\r\n            .on('open', () =>\r\n            {\r\n                // pass the sampleRate as a parameter to the server and get a reference to the communication stream.\r\n                this.speechServerStream = this.speechServerClient.createStream({\r\n                    type: 'speech',\r\n                    sampleRate: this.audioContext.sampleRate\r\n                });\r\n            })\r\n            .on('stream', (serverStream) =>\r\n            {\r\n                serverStream\r\n                    .on('data', this.onresult.bind(this))\r\n                    .on('error', this.onerror.bind(this))\r\n                    .on('close', this.onerror.bind(this))\r\n            });\r\n ```\r\n\r\nand this is my server side code\r\n\r\n```js\r\nvar options = {\r\n    config: {\r\n        encoding: 'LINEAR16',\r\n        languageCode: 'en-IN',\r\n        sampleRateHertz: 16000,\r\n    },\r\n    singleUtterance: false,\r\n    interimResults: true,\r\n    verbose: true,\r\n};\r\nvar speechClient = new Speech.SpeechClient({\r\n    projectId: environment_1.environment.gCloudProjectId,\r\n    keyFilename: 'myfile.json'\r\n});\r\n\r\n\r\n var server = new binaryjs.BinaryServer({\r\n        server: httpsServer,\r\n    });\r\n    server\r\n        .on('error', function (error) { console.log('Server error:' + error); })\r\n        .on('close', function () { console.log('Server closed'); })\r\n        .on('connection', function (client) {\r\n        client\r\n            .on('error', function (error) { console.log('Client error: ' + error); })\r\n            .on('close', function () {\r\n            console.log('Client closed.');\r\n        })\r\n            .on('stream', function (clientStream, meta) {\r\n            console.log('New Client: ' + JSON.stringify(meta));\r\n            if (meta.type === 'speech') {\r\n                handleSpeechRequest(client, clientStream, meta);\r\n            }\r\n            else {\r\n                handleRandomUtteranceRequest(client);\r\n            }\r\n        });\r\n    });\r\n}\r\nfunction handleSpeechRequest(client, clientStream, meta) {\r\n    return __awaiter(this, void 0, void 0, function () {\r\n        var speechStream;\r\n        return __generator(this, function (_a) {\r\n            switch (_a.label) {\r\n                case 0:\r\n                    options.config.sampleRateHertz = meta.sampleRate;\r\n                    return [4 /*yield*/, speechClient.streamingRecognize(options)\r\n                            .on('error', function (data) { handleGCSMessage(data, client, speechStream); })\r\n                            .on('data', function (data) {\r\n                            try {\r\n                                handleGCSMessage(data, client, speechStream);\r\n                                console.log(\"Transcription: \" + data.results[0].alternatives[0].transcript);\r\n                            }\r\n                            catch (ex) {\r\n                                console.log(ex);\r\n                            }\r\n                        })\r\n                            .on('close', function () { client.close(); })];\r\n                case 1:\r\n                    speechStream = _a.sent();\r\n                    clientStream.pipe(speechStream);\r\n                    return [2 /*return*/];\r\n            }\r\n        });\r\n    });\r\n}\r\n```\r\nPlease please tell me the solution \r\n\r\n_Copied from original issue: GoogleCloudPlatform/google-cloud-node#2860_"},"comment":{"url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/comments/423433204","html_url":"https://github.com/googleapis/nodejs-speech/issues/163#issuecomment-423433204","issue_url":"https://api.github.com/repos/googleapis/nodejs-speech/issues/163","id":423433204,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzQzMzIwNA==","user":{"login":"onofrioP89","id":8619902,"node_id":"MDQ6VXNlcjg2MTk5MDI=","avatar_url":"https://avatars2.githubusercontent.com/u/8619902?v=4","gravatar_id":"","url":"https://api.github.com/users/onofrioP89","html_url":"https://github.com/onofrioP89","followers_url":"https://api.github.com/users/onofrioP89/followers","following_url":"https://api.github.com/users/onofrioP89/following{/other_user}","gists_url":"https://api.github.com/users/onofrioP89/gists{/gist_id}","starred_url":"https://api.github.com/users/onofrioP89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onofrioP89/subscriptions","organizations_url":"https://api.github.com/users/onofrioP89/orgs","repos_url":"https://api.github.com/users/onofrioP89/repos","events_url":"https://api.github.com/users/onofrioP89/events{/privacy}","received_events_url":"https://api.github.com/users/onofrioP89/received_events","type":"User","site_admin":false},"created_at":"2018-09-21T06:55:14Z","updated_at":"2018-09-21T06:55:14Z","author_association":"NONE","body":"Hi all! In our conversational system we use Google Speech API in streaming mode such this example. The partial transcription result is very fast and we recieve a lot of response (confidence 0). \r\nUsually the final speechResult arrive after 2 second. After it we use Dialogflow to get the intent of the user and other operation on datastore. In total we need 4 o 5 seconds to answer the user. In a conversation phone based 4 o 5 second is a medium-high latency and we risk that user close the call. For workaround we set a timeout, if we don't receive a speechResult after 1 second from the last partial transcript, we use the last partial transcript as good transcription. \r\nHave got any other idea to optimize it?\r\n\r\nThanks\r\nOnofrio"}}
{"actor":{"display_login":"onofrioP89"}}