process.nextTick не является функцией нового MicrophoneStream (микрофон-stream.js: 114) на распознавать микрофон (распознавать-микрофон.js: 107) - PullRequest
1 голос
/ 14 мая 2019

Я получаю токен во внешнем интерфейсе от бэкэнда. Я получаю ошибку в var stream =ognisationMicrophone (). Оттуда он собирается в секции catch.

Я пытался https://github.com/watson-developer-cloud/speech-javascript-sdk/issues/103#issuecomment-479593656

import { Component, OnInit } from '@angular/core';
import recognizeMicrophone from 'watson-speech/speech-to-text/recognize-microphone'

@Component({
  selector: 'app-bot',
  templateUrl: './bot.component.html',
  styleUrls: ['./bot.component.css']
})
export class BotComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }


  onListenClick() {

  fetch('https://652443a9.ngrok.io/api/speech-to-text/token')
  .then(function(response) {
      return response.text();
  }).then(function (token) {
    console.log('token',token)
    var stream = recognizeMicrophone({
        token: token, // use `access_token` as the parameter name if using an RC service
        objectMode: true, // send objects instead of text
        extractResults: true, // convert {results: [{alternatives:[...]}], result_index: 0} to {alternatives: [...], index: 0}
        format: true // optional - performs basic formatting on the results such as capitals an periods
    });
    stream.on('data', function(data) {
        console.log("1111111")
      console.log(data);
    });

    stream.on('error', function(err) {
        console.log("2222222")
        console.log(err);
    });
  }).catch(function(error) {
    console.log("3333333333333")
      console.log(error);
  });

    }

}


...