我正在使用Watson-Developer-Cloud模块,以及示例:https://www.npmjs.com/package/watson-developer-cloud#speech-to-text
不幸的是,我的选择似乎都没有起作用:
timestamps: true, profanity_filter: false, word_confidence:true
我是否在正确的地方传递了它们?
var watson = require('watson-developer-cloud');
var fs = require('fs');
var speech_to_text = watson.speech_to_text({
url: "https://stream.watsonplatform.net/speech-to-text/api",
username: 'xxxxx',
password: 'xxxxx',
version: 'v1'
});
fs.createReadStream('./resources/speech.wav')
.pipe(speech_to_text.createRecognizeStream({ content_type: 'audio/l16; rate=44100', timestamps: true, profanity_filter: false, word_confidence:true }))
.pipe(fs.createWriteStream('./transcription2.txt'));
我正在收回成绩单,但我想要时间戳和置信度。这是我要回来的样本:
“五个电话远离周五”
正如您所看到的,没有时间戳,无信心分数和亵渎性语言仍然被过滤。
答案 0 :(得分:0)
我要查看识别流事件,以便更好地控制输出,例如:
// Create the stream.
var recognizeStream = speech_to_text.createRecognizeStream(params);
// Pipe in the audio.
fs.createReadStream('audio-file.wav').pipe(recognizeStream);
// Pipe out the transcription to a file.
recognizeStream.pipe(fs.createWriteStream('transcription.txt'));
// Get strings instead of buffers from 'data' events.
recognizeStream.setEncoding('utf8');
// Listen for events.
recognizeStream.on('data', function(event) { onEvent('Data:', event); });
recognizeStream.on('results', function(event) { onEvent('Results:', event); });
recognizeStream.on('error', function(event) { onEvent('Error:', event); });
recognizeStream.on('close-connection', function(event) { onEvent('Close:', event); });
// Displays events on the console.
function onEvent(name, event) {
console.log(name, JSON.stringify(event, null, 2));
};
API documentation也有一个例子。