Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

speechEventType: 'SPEECH_EVENT_UNSPECIFIED' #134

Closed
wassizafar786 opened this issue Aug 5, 2018 · 1 comment
Closed

speechEventType: 'SPEECH_EVENT_UNSPECIFIED' #134

wassizafar786 opened this issue Aug 5, 2018 · 1 comment
Assignees
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.

Comments

@wassizafar786
Copy link

wassizafar786 commented Aug 5, 2018

let options = {
  config: {
    encoding: 'LINEAR16',
    languageCode: 'en-US',
    sampleRateHertz: 16000,
    enableWordTimeOffsets: true,
    model: "default"
  },
  singleUtterance: true,
  interimResults: true,
  verbose: true
};

// handle client connections
server
.on('error', (error) => { console.log('Server error:' + error); })
.on('close', () => { console.log('Server closed'); })
.on('connection', (client) => {
  client
  .on('error', (error) => { console.log('Client error: ' + error); })
  .on('close', () => { console.log('Client closed.'); })
  .on('stream', (clientStream, meta) => {
    console.log('New Client: ' + JSON.stringify(meta));

    if (meta.type === 'speech') {
      handleSpeechRequest(client, clientStream, meta);
    } else {
      handleRandomUtteranceRequest(client);
    }
  });
});

function handleSpeechRequest(client, clientStream, meta) {
  debugger
  options.config.sampleRateHertz = meta.sampleRate;

  let speechStream = speechClient.streamingRecognize(options)
  .on('error', (data) => { handleGCSMessage(data, client, speechStream); })
  .on('data', (data) => { handleGCSMessage(data, client, speechStream); })
  .on('close', () => { client.close(); });

  clientStream.pipe(speechStream);
}

function handleRandomUtteranceRequest(client) {
  let data = getRandomSentence();
  console.log(data);

  try {
    client.send(data);
  } catch (ex) {
    console.log('Failed to send message back to client...Closed?');
  }
}

function handleGCSMessage(data, client, speechStream) {
  debugger;
  if (client && client.streams[0] &&
      client.streams[0].writable && !client.streams[0].destroyed) {
    try {
      console.log(data);

      client.send(data);
    } catch (ex) {
      console.log('Failed to send message back to client...Closed?');
    }
    if (data.error || data.Error) {
      try {
        speechStream.end();
        speechStream = null;
        client.close();
        client = null;
      } catch (ex) {
        console.log('ERROR closing the streams after error!');
      }
    }
  }
}

I am getting error please help me
the error is

{ results:
   [ { alternatives: [Array],
       isFinal: false,
       stability: 0.8999999761581421 } ],
  error: null,
  speechEventType: 'SPEECH_EVENT_UNSPECIFIED' }
@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Aug 6, 2018
@stephenplusplus
Copy link
Contributor

It's hard to reproduce issues with this API, since the audio input is crucial to get the response you're getting. However, in this case, I don't believe we're looking at an error. It looks like a normal response from the API: https://cloud.google.com/speech-to-text/docs/reference/rpc/google.cloud.speech.v1#google.cloud.speech.v1.StreamingRecognizeResponse

For general questions about how to use the Speech API, including how to handle responses, try some of the links on the Support page: https://cloud.google.com/speech-to-text/docs/support. Our help here is usually limited to just making sure we don't have any bugs in the thin layer we put up in front of the raw API.

However, if you think there could be a bug in this library, could you please elaborate on the response you expect to see? It would help to see the other information we ask for in our New Issue template: https://github.com/googleapis/nodejs-speech/blob/master/.github/ISSUE_TEMPLATE.md. Lastly, it would be great if you could provide a clone-and-run reproduction case.

Thanks!

@stephenplusplus stephenplusplus added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Aug 7, 2018
@JustinBeckwith JustinBeckwith added the needs more info This issue needs more information from the customer to proceed. label Sep 21, 2018
@google-cloud-label-sync google-cloud-label-sync bot added the api: speech Issues related to the googleapis/nodejs-speech API. label Jan 31, 2020
@JustinBeckwith JustinBeckwith self-assigned this Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: speech Issues related to the googleapis/nodejs-speech API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants