Reference documentation and code samples for the Cloud Speech V1 Client class SpeechClient.
Service Description: Service that implements Google Cloud Speech API.
Namespace
Google \ Cloud \ Speech \ V1Methods
createRecognitionAudio
Helper method to create a RecognitionAudio object from audio data.
audio
resource|string| RecognitionAudio
Required The audio data to be recognized. This can be a RecognitionAudio object, a Google Cloud Storage URI, a resource object, or a string of bytes.
createStreamingRequests
Helper method to create a stream of StreamingRecognizeRequest objects from audio data.
audio
Traversable
|resource|string
Required The audio data to be converted into a stream of requests. This can be a resource, a string of bytes, or an iterable of StreamingRecognizeRequest[] or string[].
recognizeAudioStream
Performs speech recognition on a stream of audio data. This method is only available via the gRPC API (not REST).
Example:
use Google\Cloud\Speech\V1\RecognitionConfig_AudioEncoding;
use Google\Cloud\Speech\V1\RecognitionConfig;
use Google\Cloud\Speech\V1\StreamingRecognitionConfig;
$recognitionConfig = new RecognitionConfig();
$recognitionConfig->setEncoding(RecognitionConfig_AudioEncoding::FLAC);
$recognitionConfig->setSampleRateHertz(44100);
$recognitionConfig->setLanguageCode('en-US');
$config = new StreamingRecognitionConfig();
$config->setConfig($recognitionConfig);
$audioResource = fopen('path/to/audio.flac', 'r');
$responses = $speechClient->recognizeAudioStream($config, $audioResource);
foreach ($responses as $element) {
// doSomethingWith($element);
}
config
StreamingRecognitionConfig
Required Provides information to the recognizer that specifies how to process the request.
audio
Traversable
|resource|string
Required Audio data to be streamed. Can be a resource, a string of bytes, or an iterable of StreamingRecognizeRequest[] or string[].
optionalArgs
array
Optional.
↳ timeoutMillis
int
Timeout to use for this call.