无法将音频转换为文本nodejs

Unable to covert audio to text nodejs

我正在尝试使用节点 js 将音频文件转换为文本,我有一个参考 link https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/speech,通过使用这个 link 我可以转换示例文件其中包括(即 audio.raw、gs://gcs-test-data/vr.flac)从音频到文本

但是当我使用此 link 中的音频文件时,我无法将音频转换为文本,它显示为空响应。响应是 { results: [] }

我也知道使用这些命令

 node recognize.js sync ./resources/audio.raw -e LINEAR16 -r 16000
 node recognize.js async-gcs gs://gcs-test-data/vr.flac -e FLAC -r 16000
 node recognize.js stream ./resources/audio.raw  -e LINEAR16 -r 16000

但是,我不知道如何使用 link 中的音频文件将音频转换为文本

使用 Google 语音 API 时,务必确保您的音频格式正确。 API 不能用于 mp3 等格式。

为了使用 api 您可以使用 sox 或 ffmpeg 等工具将其转换为 flac: * 袜子:sox input_file.mp3 output.flac * ffmpeg: ffmpeg -i input_file.mp3 ./output.flac

如果使用了错误的格式,Google 语音 API 将返回空答案。

{ results: [] }