1. Go to this page and download the library: Download noardcode/speech-to-text library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
noardcode / speech-to-text example snippets
/*
|--------------------------------------------------------------------------
| Google Service Account
|--------------------------------------------------------------------------
*/
'service-account' => '/path/to/service-account.json',
// Run on Google Cloud Storage object
resolve(SpeechToText::class)->run('gs://your-bucket-name/path-to-object');
// Run on stored audio file (needs to be: less than 10MB in size and less than 1 minute in length)
resolve(SpeechToText::class)
->setAudio(new FilesystemAudio)
->run('/path/to/audio-file');
// Using different types of transcripts (e.g.
/*
|--------------------------------------------------------------------------
| Default parameters injected by the Service Provider
|--------------------------------------------------------------------------
*/
'defaults' => [
'language' => 'en-US',
'encoding' => \Google\Cloud\Speech\V1\RecognitionConfig\AudioEncoding::LINEAR16,
'sampleRateHertz' => 44100
]