当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - IBM Watson Speech to Text API with node. How to output to DOM?

问题描述:

I am using a npm module to work with IBM's Watson to do speech to text. I'm using this package here: https://github.com/watson-developer-cloud/speech-javascript-sdk.

I can authenticate fine, but other than that nothing happens. I want to take the text from the response and insert it in the DOM. I tried the following just to try it out and I'm not getting any kind of feedback.

WatsonSpeech.SpeechToText.recognizeMicrophone({token: token, keepmic: true, ouputElement: "body"}).promise().then(function() {

console.log("talking");

})

The docs say the following for this method:

Other options passed to WritableElementStream if options.outputElement

is set.

And

Pipes results through a FormatStream by default, set options.format=false > to disable.

I would think that the

WatsonSpeech.SpeechToText.recognizeMicrophone

would take a callback function so I can handle the response and put insert it in my DOM, but I can't figure that out. Also, I'm not really a JS guy, so I don't know what the promise does.

分享给朋友:
您可能感兴趣的文章:
随机阅读: