最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

如何在Google云端语音库中为Node JS启用说话者区分?

IT培训 admin 3浏览 0评论

如何在Google云端语音库中为Node JS启用说话者区分?

我目前正在尝试创建一个使用Google云语音转文本的网络应用,尤其是说话者区分功能。我的服务器是用节点js编写的,我正在将音频文件作为Google存储URI发送。我的语音配置看起来像这样

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

和我要返回的成绩单有一个空的'words'数组,谷歌云语音文档告诉我该数组应包含发言人标签:

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

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

enableWordTimeOffsets: true,

到我的配置,然后我得到一个'words'数组,像这样:

[ { 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;

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

回答如下:

Hello world]

console.log('Hello world');

如何在Google云端语音库中为Node JS启用说话者区分?

我目前正在尝试创建一个使用Google云语音转文本的网络应用,尤其是说话者区分功能。我的服务器是用节点js编写的,我正在将音频文件作为Google存储URI发送。我的语音配置看起来像这样

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

和我要返回的成绩单有一个空的'words'数组,谷歌云语音文档告诉我该数组应包含发言人标签:

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

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

enableWordTimeOffsets: true,

到我的配置,然后我得到一个'words'数组,像这样:

[ { 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;

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

回答如下:

Hello world]

console.log('Hello world');
发布评论

评论列表 (0)

  1. 暂无评论