I'm new to all this, so please be gentle. I know basic php and have WAMP installed on my computer. All I need is a simple way to transcribe audio files. I have the google cloud shell sdk installed and used that to have composer install the required files (copied and pasted the command from google's tutorial), which it put in a vendor folder.
I then modified the php code google put on github which I'll paste below. When I try to run the php file, however, I get the following error message(s). What am I doing wrong? :(
<?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;