Property | Type | Description | |
---|---|---|---|
$connection | Google\Cloud\Speech\Connection\ConnectionInterface |
Method | Description | |
---|---|---|
__construct ( array $config = [] ) | Create a Speech client. | |
beginRecognizeOperation ( resource | string | |
Runs a recognize request as an operation. Ideal when working with audio longer than approximately one minute. Requires polling of the returned operation in order to fetch results. | |
operation ( string $name ) : |
Lazily instantiates an operation. There are no network requests made at this point. To see the operations that can be performed on an operation please see {@see Google\Cloud\Speech\Operation}. | |
recognize ( resource | string | |
Runs a recognize request and returns the results immediately. Ideal when working with audio up to approximately one minute in length. |
Method | Description | |
---|---|---|
analyzeAudio ( resource | string | |
Analyzes the provided audio using the getid3() library. | |
determineEncoding ( string $fileFormat ) : string | null | Attempts to determine the encoding based on the file format. | |
determineSampleRate ( string $encoding ) : integer | null | Attempts to determine the sample rate based on the encoding. | |
formatRequest ( resource | string | |
Formats the request for the API. | |
getTempResource ( resource | string $audio ) : resource | Takes in a resource or string and makes sure it is available as a local file in order for the getID3 library to be able to analzye it. | |
isRemoteResource ( resource $audio ) : boolean | Determines if the resource provided is remote. |
public __construct ( array $config = [] ) | ||
$config | array | [optional] { Configuration Options. @type string $projectId The project ID from the Google Developer's Console. @type CacheItemPoolInterface $authCache A cache for storing access tokens. **Defaults to** a simple in memory implementation. @type array $authCacheOptions Cache configuration options. @type callable $authHttpHandler A handler used to deliver Psr7 requests specifically for authentication. @type callable $httpHandler A handler used to deliver Psr7 requests. Only valid for requests sent over REST. @type string $keyFile The contents of the service account credentials .json file retrieved from the Google Developers Console. @type string $keyFilePath The full path to your service account credentials .json file retrieved from the Google Developers Console. @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type array $scopes Scopes to be used for the request. } |
public beginRecognizeOperation ( resource | string | |
||
$audio | resource | string | |
The audio to recognize. May be a resource, string of bytes, or Google Cloud Storage object. |
$options | array | [optional] { Configuration options. @type int $sampleRate Sample rate in Hertz of the provided audio. Valid values are: 8000-48000. 16000 is optimal. For best results, set the sampling rate of the audio source to 16000 Hz. If that's not possible, use the native sample rate of the audio source (instead of re-sampling). **Defaults to** `8000` with .amr files and `16000` with .awb files. If the getID3 library has been installed this value will default to the value read from the file's headers (if it exists). @type string $encoding Encoding of the provided audio. May be one of `"LINEAR16"`, `"FLAC"`, `"MULAW"`, `"AMR"`, `"AMR_WB"`. **Defaults to** `"FLAC"` with .flac files, `"AMR"` with .amr files and `"AMR_WB"` with .awb files. @type int $maxAlternatives Maximum number of alternatives to be returned. Valid values are 1-30. **Defaults to** `1`. @type string $languageCode The language of the content. BCP-47 (e.g., `"en-US"`, `"es-ES"`) language codes are accepted. **Defaults to** `"en"` (English). @type bool $profanityFilter If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. \"f***\". **Defaults to** `false`. @type array $speechContext Must contain a key `phrases` which is to be an array of strings which provide "hints" to the speech recognizer to favor specific words and phrases in the results. Please see [SpeechContext](https://cloud.google.com/speech/reference/rest/v1beta1/RecognitionConfig#SpeechContext) for more information. } |
return |
public recognize ( resource | string | |
||
$audio | resource | string | |
The audio to recognize. May be a resource, string of bytes, or Google Cloud Storage object. |
$options | array | [optional] { Configuration options. @type int $sampleRate Sample rate in Hertz of the provided audio. Valid values are: 8000-48000. 16000 is optimal. For best results, set the sampling rate of the audio source to 16000 Hz. If that's not possible, use the native sample rate of the audio source (instead of re-sampling). **Defaults to** `8000` with .amr files and `16000` with .awb files. If the getID3 library has been installed this value will **default to** the value read from the file's headers (if they exists). @type string $encoding Encoding of the provided audio. May be one of `"LINEAR16"`, `"FLAC"`, `"MULAW"`, `"AMR"`, `"AMR_WB"`. **Defaults to** `"FLAC"` with .flac files, `"AMR"` with .amr files and `"AMR_WB"` with .awb files. @type int $maxAlternatives Maximum number of alternatives to be returned. Valid values are 1-30. **Defaults to** `1`. @type string $languageCode The language of the content. BCP-47 (e.g., `"en-US"`, `"es-ES"`) language codes are accepted. **Defaults to** `"en-US"` (English). @type bool $profanityFilter If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. \"f***\". **Defaults to** `false`. @type array $speechContext Must contain a key `phrases` which is to be an array of strings which provide "hints" to the speech recognizer to favor specific words and phrases in the results. Please see [SpeechContext](https://cloud.google.com/speech/reference/rest/v1beta1/RecognitionConfig#SpeechContext) for more information. } |
return | array | The transcribed results. Each element of the array contains a `transcript` key which holds the transcribed text. Optionally a `confidence` key holding the confidence estimate ranging from 0.0 to 1.0 may be present. `confidence` is typically provided only for the top hypothesis. |