node-wrtc音频流语音到文本

时间:2020-09-13 16:56:35

标签: google-cloud-speech

我正在将音频数据从webrtc客户端流传输到node-wrtc。我能够获取node-wrtc(节点webrtc)以将音频缓冲区流式传输到ffmpeg并写入文件。但我想将缓冲区直接流式传输到Google Speech API,而无需写入/读取文件。

我正在使用通过webrtc流式传输的mulaw 8000 hz PCMU。我已将Google配置设置为对它进行编码。

从node-wrtc产生输出结果的代码:

    log.info('onAudioData', audioData);
    log.info('audioData.samples.length', audioData.samples.length);
    const buf = new Buffer.from(audioData.samples);
    log.info('buf', buf);
    recognizeStream.write(buf);

输出结果:

onAudioData {
  samples: Int16Array(80) [
     16, -16, -16,  32, 16,  16,   0, -16,  -8, -32, -32,  -8,
      0,   0,   0,  16, 32,  24,  16, -16, -32,  16,  24,   8,
    -16, -16,   0,  -8,  8,  16,   8,  16,   0, -32, -48, -48,
    -16,   8,  24,  32,  0,  -8,  16,  24,  32,  16,  -8, -24,
      0,  16,   8,   8, -8, -24, -32, -16,   8,  24,   0,   8,
     16,   0,   0,   8,  0,  -8,  32,  40, -24, -56,  16,  48,
     24,   0, -40, -16, -8, -32, -32,  16
  ],
  bitsPerSample: 16,
  sampleRate: 8000,
  channelCount: 1,
  numberOfFrames: 80,
  type: 'data'
}
audioData.samples.length 80
buf <Buffer 10 f0 f0 20 10 10 00 f0 f8 e0 e0 f8 00 00 00 10 20 18 10 f0 e0 10 18 08 f0 f0 00 f8 08 10 08 10 00 e0 d0 d0 f0 08 18 20 00 f8 10 18 20 10 f8 e8 00 10 ... 30 more bytes>

我的问题是,我没有从Google得到任何回报。仪表板中没有错误或指标。

我需要了解如何对从node-wrtc获得的样本进行编码,并将其馈送到RecognizeStream。理想情况下,我会使用Opus,但我希望PCMU能够正常运行,因为它似乎符合配置规范(Google表示它接受OGG_OPUS,但不确定如何从实时流中执行此操作)。

0 个答案:

没有答案