微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在 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 举报,一经查实,本站将立刻删除。