【问题标题】:How to enable speaker diarization in Google Cloud Speech library for Node JS?如何在 Node JS 的 Google Cloud Speech 库中启用扬声器分类?
【发布时间】:2019-04-02 16:38:25
【问题描述】:

我目前正在尝试创建一个使用谷歌云语音到文本的网络应用程序,特别是扬声器分类功能。我的服务器是用节点 js 编写的,我将音频文件作为谷歌存储 URI 发送。我的语音配置如下所示

config: {
          encoding: 'LINEAR16',
          languageCode: 'en-GB',
          sampleRateHertz: 8000,
          enableSpeakerDiarization: true,
          diarizationSpeakerCount: true,
        }

我得到的成绩单有一个空的“单词”数组,谷歌云语音文档告诉我应该包含演讲者标签:

{ words: [],
transcript: 'and the rabbit sails at dusk',
confidence: 0.8659023642539978 }

值得注意的是,如果我添加

enableWordTimeOffsets: true,

到我的配置然后我得到一个像这样的“单词”数组:

[ { startTime: { seconds: '0', nanos: 0 },
endTime: { seconds: '0', nanos: 600000000 },
word: 'Hello' } etc..

更新

我没有正确导入 nodejs 谷歌云语音库,我这样做了:

const speech = require('@google-cloud/speech');

为了使用 beta 功能,我需要使用这个:

const speech = require('@google-cloud/speech').v1p1beta1;

在我进行此更改后,问题已解决。

【问题讨论】:

    标签: node.js google-speech-api


    【解决方案1】:

    配置应该是这样的

    const config = {
            encoding: 'LINEAR16',
            sampleRateHertz: 8000,
            languageCode: 'en-GB'
            enableAutomaticPunctuation: true,
            useEnhanced: true,
            model: 'video',
            diarizationConfig : {
              enableSpeakerDiarization: true,
              minSpeakerCount: 2,
              maxSpeakerCount: 3,
          }
        }

    有关 RecognitionConfig 的更多信息,请访问

    https://cloud.google.com/speech-to-text/docs/reference/rest/v1p1beta1/RecognitionConfig

    【讨论】:

      猜你喜欢
      • 2014-01-29
      • 2016-10-18
      • 2017-11-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-24
      • 1970-01-01
      • 2016-12-02
      • 2018-05-22
      相关资源
      最近更新 更多