Node.js 如何在IBMWatson中使用NodeJS将语音转换为文本

Node.js 如何在IBMWatson中使用NodeJS将语音转换为文本,node.js,ibm-cloud,ibm-watson,speech-to-text,Node.js,Ibm Cloud,Ibm Watson,Speech To Text,我们正在尝试使用IBMWatson中的NodeJS进行语音到文本转换。我们在IBMCloud中创建了NodeJS应用程序和语音到文本服务器。我们可以使用NodeJSAPI()将音频文件转换为文本 现在我们需要录音,而录音需要将语音转换成文本。谁能指导我们需要做什么 var SpeechToTextV1 = require('ibm-watson/speech-to-text/v1'); var fs = require('fs'); var speechToText = new SpeechTo

我们正在尝试使用IBMWatson中的NodeJS进行语音到文本转换。我们在IBMCloud中创建了NodeJS应用程序和语音到文本服务器。我们可以使用NodeJSAPI()将音频文件转换为文本

现在我们需要录音,而录音需要将语音转换成文本。谁能指导我们需要做什么

var SpeechToTextV1 = require('ibm-watson/speech-to-text/v1');
var fs = require('fs');
var speechToText = new SpeechToTextV1({
  username: 'apikey',
  password: '{apikey}',
  url: 'https://{icp_cluster_host}{:port}/speech-to-text/api'
});
var params = {
  objectMode: true,
  content_type: 'audio/flac',
  model: 'en-US_BroadbandModel',
  keywords: ['colorado', 'tornado', 'tornadoes'],
  keywords_threshold: 0.5,
  max_alternatives: 3
};
// Create the stream.
var recognizeStream = speechToText.recognizeUsingWebSocket(params);
// Pipe in the audio.
fs.createReadStream('audio-file.flac').pipe(recognizeStream);
recognizeStream.on('data', function(event) { onEvent('Data:', event); });
recognizeStream.on('error', function(event) { onEvent('Error:', event); });
recognizeStream.on('close', function(event) { onEvent('Close:', event); });
基于节点API,我们将音频文件转换为文本。现在我们希望微型手机的音频需要转换为文本。我们不知道该怎么做

期望图像


当按住微型手机时,它应该将音频转换为文本文件中的文本。请指导我们。

我不明白你的问题。您是否有要共享的编写代码?GitHub上的SDK repo中有一些代码示例可用于adapt@data_henrik谢谢你的回复。是的,我们将更新代码请帮助我建议检查,它有什么你正在寻找的例子