如何在 ibm watson 中使用节点 js 将语音转换为文本

问题描述

我们正在 ibm watson 中尝试使用节点 js 进行语音到文本。我们在 ibm 云中创建了节点 js 应用程序和语音到文本服务器。我们能够使用 node js APIs(https://cloud.ibm.com/apidocs/speech-to-text)

将音频文件转换为文本

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

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); });

基于Node API,我们将音频文件转换为文本。现在我们预计麦克风音频需要转换为文本。我们不知道该怎么做

预期图像

enter image description here

当拿着麦克风时,它应该将音频转换为文本文件中的文本。请指导我们。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)