Watson NarrowBand Speech to Text 不接受 ogg 文件

Watson NarrowBand Speech to Text not accepting ogg file

NodeJS 应用程序使用 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 是 mp3(来自 phone 录音的窄带)或 mp4(宽带) model: _voice 已追踪确保正确设置 content_type: _contentType 已追踪确保设置正确

提交给带有窄带设置的 Speech to Text 的任何 ogg 文件都会失败,Error: No speech detected for 30s. 测试了两个真实的窄带文件并要求 Watson 将宽带 ogg 文件(从 mp4 创建)读取为窄带。同样的错误信息。我错过了什么?

Watson Speech to Text 的文档在这一点上令人困惑。文档 here 指出当使用窄带模型时,content_type 应该设置为 audio/basic。那是不正确的。在这个例子中,入站音频文件是一个窄带文件,但它是一个 ogg 文件,所以 content_type 应该仍然是 audio/ogg。那个单一的变化解决了这个问题。