PHP Class Google\Cloud\Speech\Operation

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $speech = $cloud->speech(); $audioFileStream = fopen(__DIR__ . '/audio.flac', 'r'); $operation = $speech->beginRecognizeOperation( $audioFileStream );
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php

Public Methods

Method Description
__construct ( Google\Cloud\Speech\Connection\ConnectionInterface $connection, string $name, array $info = [] )
exists ( array $options = [] ) : boolean Check whether or not the operation exists.
info ( array $options = [] ) : array Retrieves the operation's details. If no data is cached a network request will be made to retrieve it.
isComplete ( array $options = [] ) : boolean Check whether or not the operation is complete. A network request will be triggered if no cached data exists.
name ( ) : string Returns the operation's name.
reload ( array $options = [] ) : array Triggers a network request to reload the operation's details.
results ( array $options = [] ) : array Retrieves the results of the operation. A network request will be triggered if no cached data exists.

Method Details

__construct() public method

public __construct ( Google\Cloud\Speech\Connection\ConnectionInterface $connection, string $name, array $info = [] )
$connection Google\Cloud\Speech\Connection\ConnectionInterface Represents a connection to the Google Cloud Speech API.
$name string The operation's name.
$info array [optional] The operation's data.

exists() public method

Example: if ($operation->exists()) { echo "The operation exists."; }
public exists ( array $options = [] ) : boolean
$options array [optional] Configuration Options.
return boolean

info() public method

Example: $info = $operation->info(); print_r($info['response']);
See also: https://cloud.google.com/speech/reference/rest/v1beta1/operations/get Operations get API documentation.
See also: https://cloud.google.com/speech/reference/rest/v1beta1/operations#Operation Operation resource documentation.
public info ( array $options = [] ) : array
$options array [optional] Configuration Options.
return array

isComplete() public method

Example: if ($operation->isComplete()) { echo "The operation is complete!"; }
public isComplete ( array $options = [] ) : boolean
$options array [optional] Configuration Options.
return boolean

name() public method

Example: echo $operation->name();
public name ( ) : string
return string

reload() public method

Example: $operation->reload(); $info = $operation->info(); print_r($info['response']);
See also: https://cloud.google.com/speech/reference/rest/v1beta1/operations/get Operations get API documentation.
See also: https://cloud.google.com/speech/reference/rest/v1beta1/operations#Operation Operation resource documentation.
public reload ( array $options = [] ) : array
$options array [optional] Configuration Options.
return array

results() public method

Example: if ($operation->isComplete()) { $results = $operation->results(); }
See also: https://cloud.google.com/speech/reference/rest/v1beta1/speech/syncrecognize#SpeechRecognitionAlternative SpeechRecognitionAlternative
public results ( array $options = [] ) : array
$options array [optional] Configuration Options.
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.