尝试运行Google Cloud语音转录时出现服务异常错误60

时间:2018-09-26 19:02:50

标签: php google-cloud-platform google-speech-api

我是这一切的新手,请保持温柔。我知道基本的php,并且在我的计算机上安装了WAMP。我需要的只是转录音频文件的简单方法。我安装了google cloud shell sdk,并用它来使作曲家安装所需的文件(从google教程中复制并粘贴命令),并将其放置在供应商文件夹中。

然后我修改了Google放在github上的php代码,我将在下面粘贴。但是,当我尝试运行php文件时,出现以下错误消息。我究竟做错了什么? :(

enter image description here

<?php

# [START speech_quickstart]
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';


# Imports the Google Cloud client library
use Google\Cloud\Speech\SpeechClient;


# Your Google Cloud Platform project ID
$projectId = 'xxxx';


# Instantiates a client
$speech = new SpeechClient([
    'projectId' => $projectId,
    'languageCode' => 'en-US',
]);


# The name of the audio file to transcribe
$fileName = __DIR__ . '/audio/transcribe.mp3';


# The audio file's encoding and sample rate
$options = [
    'encoding' => 'LINEAR16',
    'sampleRateHertz' => 16000,
    'languageCode' => 'en-US',
    'enableWordTimeOffsets' => false,
    'enableAutomaticPunctuation' => true,
    'model' => 'video',
];


# Detects speech in the audio file
$results = $speech->recognize(fopen($fileName, 'r'), $options);
foreach ($results as $result) {
    echo 'Transcription: ' . $result->alternatives()[0]['transcript'] . PHP_EOL;
}


# [END speech_quickstart]
return $results;

1 个答案:

答案 0 :(得分:0)

错误消息表明cURL没有可用的证书颁发机构的证书列表,因此无法验证与Google的连接的完整性。 this answer中的步骤应该可以解决问题。