Преобразование речи в текст Bing Speech API Azure

Когда я пытаюсь выполнить приведенный ниже код, я получаю следующую ошибку:

var fs = require('fs');
var bing = require('bingspeech-api-client');

var audioStream = fs.createReadStream('d:\\node.wav'); 
var subscriptionKey = 'xxxxxxxxxxxxxxxxx';

var client = new bing.BingSpeechClient(subscriptionKey);
client.recognizeStream(audioStream)
      .then(response => console.log(response.results[0].name));

Пожалуйста помогите.


person Lokesh Avichetty    schedule 03.03.2017    source источник
comment
Привет, Адхит, у тебя есть обновления?   -  person Gary Liu    schedule 17.03.2017
comment
Я завершил модуль с IBM Watson. Сегодня я собираюсь разобраться в этих вещах, о которых я дам вам знать как можно скорее.   -  person Lokesh Avichetty    schedule 18.03.2017
comment
все та же ошибка Гэри   -  person Lokesh Avichetty    schedule 30.03.2017


Ответы (4)


Я пробовал использовать ваш фрагмент кода и пример аудиофайла в репозитории по адресу https://github.com/palmerabollo/bingspeech-api-client/tree/master/examples. На моей стороне он отлично работает.

Погрузившись в исходный код, я обнаружил, что
throw new Error(`Voice recognition failed miserably: ${err.message}`);
выдает сообщение об ошибке по адресу https://github.com/palmerabollo/bingspeech-api-client/blob/master/src/client..ts#L129

Обычно это проблема с Интернетом, пожалуйста, дважды проверьте свою работу в Интернете, или вы можете попробовать ping url https://api.cognitive.microsoft.com/sts/v1.0/issueToken, чтобы проверить, нет ли у вас проблем с подключением к API.

person Gary Liu    schedule 06.03.2017

Возникла проблема во время игры с сервисом, и это было связано с настройками тайм-аута, жестко запрограммированными в bingspeech-api-client в строке 110:

open_timeout: 5000,

Полный код здесь.

Вы можете попробовать установить более высокие значения в зависимости от вашего интернет-соединения.

person Deams    schedule 03.05.2017
comment
Я пробовал использовать несколько значений от 10000 до 50000, но все равно не работает. Имеет ли значение битрейт файла wav? - person Lokesh Avichetty; 05.05.2017

если вы находитесь за прокси-сервером, попробуйте установить прокси в файле node_modules \ bingspeech-api-client \ lib \ client.js, используя

https-прокси-агент

в опции всего HTTP-запроса включить токен задачи.

person Elf    schedule 12.07.2017

Код ниже работает для меня

const { BingSpeechClient, VoiceRecognitionResponse } = require('bingspeech-api-client');
const fs = require('fs');
let audioStream = fs.createReadStream("audiowav.wav"); 

// Bing Speech Key (https://www.microsoft.com/cognitive-services/en-us/subscriptions)
let subscriptionKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';         
let client = new BingSpeechClient(subscriptionKey);

          client.recognizeStream(audioStream).then(function(response)
          {
            console.log("response is ",response);
            console.log("-------------------------------------------------");
            console.log("response is ",response.results[0]);
          }).catch(function(error)
          {
            console.log("error occured is ",error);
          });

Я думаю, вам нужно импортировать как BingSpeechClient, так и VoiceRecognitionResponse из bingspeech-api-client. Вот ссылка bingspeech-api-client

person Muthu Prasanth    schedule 24.07.2018