首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google speech to text api延迟问题

问Google speech to text api延迟问题
EN

Stack Overflow用户
提问于 2020-01-13 00:53:10
回答 1查看 164关注 0票数 0

我尝试使用Google speech to text API将音频文件(WAV格式)转换为文本,并对响应时间进行了查询。下面是代码和响应持续时间。

音频文件大小约为30kb,长度为3秒。语音转文本服务大约花了1.7秒来转录,我认为这太高了,应该在毫秒内。这是正常的还是我遗漏了一些配置?

感谢您的建议。

代码语言:javascript
复制
const speech = require('@google-cloud/speech');
const fs = require('fs');

// Creates a client
const client = new speech.SpeechClient();

// The name of the audio file to transcribe
const fileName = 'xxx.wav';

// Reads a local audio file and converts it to base64
const file = fs.readFileSync(fileName);
const audioBytes = file.toString('base64');


// The audio file's encoding, sample rate in hertz, and BCP-47 language code
const audio = {
content: audioBytes,
};
const config = {
encoding: 'MULAW',
sampleRateHertz: 8000,
languageCode: 'en-GB',
model: 'default',
use_enhanced: 'true',
metadata: {InteractionType: 'VOICE_SEARCH',
microphoneDistance: 'NEARFIELD',
OriginalMediaType: 'AUDIO',
RecordingDeviceType: 'PHONE_LINE'},
};
const request = {
audio: audio,
config: config,
};

const [response] = await client.recognize(request);

const transcription = response.results
.map(result => result.alternatives[0].transcript)
.join('\n');
console.log(`Transcription: ${transcription}`);
EN

回答 1

Stack Overflow用户

发布于 2020-01-13 01:55:35

请检查您的网络连接速度(网速)

如果您的网络速度较慢,则整体响应时间会更长。

检查文件上传到google云的时间。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59706056

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档