Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 谷歌语音到文本(语音识别)只识别音频的前几秒钟_Google Cloud Platform_Speech Recognition_Speech To Text_Google Speech Api - Fatal编程技术网

Google cloud platform 谷歌语音到文本(语音识别)只识别音频的前几秒钟

Google cloud platform 谷歌语音到文本(语音识别)只识别音频的前几秒钟,google-cloud-platform,speech-recognition,speech-to-text,google-speech-api,Google Cloud Platform,Speech Recognition,Speech To Text,Google Speech Api,我在NodeJS中使用Google的语音到文本API。它返回对前几个单词的识别,但随后忽略音频文件的其余部分。任何上传文件的截止时间约为5-7秒 我试过了。 (使用MP3文件的示例如下所示) 我也试过了 (使用WAV文件的示例如下所示) 我已经用WAV文件和MP3尝试了这些实现。结果总是一模一样的:前5秒钟识别良好,然后什么都没有 任何帮助都将不胜感激 @Ricco D绝对正确,我打印的结果不正确 当您尝试转录较长的文件时,Google Speech to Text会根据检测到语音暂停的时间来中

我在NodeJS中使用Google的语音到文本API。它返回对前几个单词的识别,但随后忽略音频文件的其余部分。任何上传文件的截止时间约为5-7秒

我试过了。 (使用MP3文件的示例如下所示)

我也试过了 (使用WAV文件的示例如下所示)

我已经用WAV文件和MP3尝试了这些实现。结果总是一模一样的:前5秒钟识别良好,然后什么都没有


任何帮助都将不胜感激

@Ricco D绝对正确,我打印的结果不正确

当您尝试转录较长的文件时,Google Speech to Text会根据检测到语音暂停的时间来中断您的转录

您的response.results[]数组将包含多个条目,您需要循环这些条目来打印完整的成绩单

有关更多详细信息,请参阅文档:

您如何打印结果?您是否像您遵循的示例代码一样打印结果?
    filename = './TEST/test.mp3';

    const client = new speech.SpeechClient();

    //configure the request:
    const config = {
        enableWordTimeOffsets: true,
        sampleRateHertz: 44100,
        encoding: 'MP3',
        languageCode: 'en-US',
    };
    const audio = {
        content: fs.readFileSync(filename).toString('base64'),
    };
    const request = {
        config: config,
        audio: audio,
    };
    
    // Detects speech in the audio file
    const [response] = await client.recognize(request);
filename = './TEST/test.wav';

const client = new speech.SpeechClient();

//configure the request:
const config = {
     enableWordTimeOffsets: true,
     languageCode: 'en-US',
};
const audio = {
     content: fs.readFileSync(filename).toString('base64'),
};
const request = {
     config: config,
     audio: audio,
};

//Do a longRunningRecognize request
const [operation] = await client.longRunningRecognize(request);
const [response] = await operation.promise();