我是这一切的新手,请保持温柔。我知道基本的php,并且在我的计算机上安装了WAMP。我需要的只是转录音频文件的简单方法。我安装了google cloud shell sdk,并用它来使作曲家安装所需的文件(从google教程中复制并粘贴命令),并将其放置在供应商文件夹中。
然后我修改了Google放在github上的php代码,我将在下面粘贴。但是,当我尝试运行php文件时,出现以下错误消息。我究竟做错了什么? :(
<?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;