Google Speech to Text 最佳值

Google Speech to Text optimal values

我正在尝试优化 Node.js 应用程序中的 Speech to Text 调用值。我正在尝试确定它们是否是当前的最佳实践。

我了解 Speech to Text 推荐使用 16,000Hz 采样率的 LINEAR16 编码,但这对于以 8000hz 发送的 VOIP 是不可能的,目前 Twilio 仅提供 MULAW 编码。

我想知道的是用于“模型”“use_enhanced”和“置信度”的值是否合适?

if (this.newStreamRequired()) {
  if (this.stream) {
    this.stream.destroy();
  }

  var request = {
    config: {
      encoding: "MULAW",
      sampleRateHertz: 8000,
      languageCode: "en-US",
      model: 'phone_call',
      use_enhanced: true,
      confidence: 1.0
    },
    single_utterance: false,
    interimResults: false,
    is_final: true
    
  };

  this.streamCreatedAt = new Date();
  this.stream = speech
    .streamingRecognize(request)
    .on("error", console.error)
    .on("data", (data) => {
      const result = data.results[0];
       if (result === undefined || result.alternatives[0] === undefined) {
         return;
       } 
      this.emit('transcription', result.alternatives[0].transcript);
    });
}

一般来说,很难评估您的选择是否确实是最好的。您可以采取的最佳方法是研究备选方案,运行 进行几次测试并坚持使用产生最佳结果的参数。

无论如何,让我们检查一下您的具体情况:

  • 型号:8000Hz 的最佳型号是phone_call,如here 中所述。其他替代方案更适合 16000Hz 音频。
  • Use_enhanced:只有true/false选项。 运行 使用这两种方法进行测试应该很容易。在纸面上,使用增强模型应该会产生更好的结果,尤其是对于 phone call 模型 (see).
  • 置信度:该字段通常是response, I don’t think it can be included in the default request config. Notice that a streaming config中的一个值,基于默认配置。

总而言之,我认为您的请求参数具有正确的值,除了可能不适合请求参数的置信度值。