Nodeff应用程序使用ffmpeg从mp3和mp4创建ogg文件。如果源文件是宽带文件,则Watson Speech to Text会接受该文件,不会有任何问题。如果源文件是窄带,则Watson Speech to Text无法读取ogg文件。我已经测试了ffmpeg的输出,并且窄带ogg文件具有与mp3文件相同的音频内容(例如,我可以听并听到相同的人的声音)。是的,预先,我正在更改对Watson的调用,以正确指定模型和content_type。代码如下:
exports.createTranscript = function(req, res, next)
{ var _name = getNameBase(req.body.movie);
var _type = getType(req.body.movie);
var _voice = (_type == "mp4") ? "en-US_BroadbandModel" : "en-US_NarrowbandModel" ;
var _contentType = (_type == "mp4") ? "audio/ogg" : "audio/basic" ;
var _audio = process.cwd()+"/HTML/movies/"+_name+'ogg';
var transcriptFile = process.cwd()+"/HTML/movies/"+_name+'json';
speech_to_text.createSession({model: _voice}, function(error, session) {
if (error) {console.log('error:', error);}
else
{
var params = { content_type: _contentType, continuous: true,
audio: fs.createReadStream(_audio),
session_id: session.session_id
};
speech_to_text.recognize(params, function(error, transcript) {
if (error) {console.log('error:', error);}
else
{ fs.writeFile(transcriptFile, JSON.stringify(transcript), function(err) {if (err) {console.log(err);}});
res.send(transcript);
}
});
}
});
}
_type
是否model: _voice
已跟踪mp3(电话录音的窄带)或mp4(宽带)以确保content_type: _contentType
已跟踪正确的设置以确保正确的设置
带有窄带设置的任何提交给语音转换为文本的ogg文件Error: No speech detected for 30s.
均无法通过“真实窄带文件测试”并要求Watson读取宽带ogg文件(从mp4创建)作为窄带而失败。相同的错误消息。我想念什么?
Watson语音转文本文档在这一点上令人困惑。此处的文档指出,在使用窄带模型时,content_type
应将其设置为audio/basic
。那是不对的。在此示例中,入站音频文件是一个窄带文件,但它是一个ogg文件,因此content_type
仍应为audio/ogg
。单个更改解决了该问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句