Skip to content

Commit

Permalink
feat: add processing strategy to batch recognition requests (#6211)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 530882015
Source-Link: googleapis/googleapis@189bdfa
Source-Link: googleapis/googleapis-gen@64c7a84
Copy-Tag: eyJwIjoiU3BlZWNoLy5Pd2xCb3QueWFtbCIsImgiOiI2NGM3YTg0M2FmZGRhOGM2NTFmZmNhNmUxYTM3NGFjNzgwMWQzNzI4In0=
  • Loading branch information
gcf-owl-bot[bot] authored May 11, 2023
1 parent ec90369 commit 0ef2434
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 238 deletions.
Binary file modified Speech/metadata/V2/CloudSpeech.php
Binary file not shown.
53 changes: 8 additions & 45 deletions Speech/samples/V2/SpeechClient/create_recognizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,17 @@
* @param string $recognizerModel Which model to use for recognition requests. Select the model
* best suited to your domain to get best results.
*
* Supported models:
*
* - `latest_long`
*
* Best for long form content like media or conversation.
*
* - `latest_short`
*
* Best for short form content like commands or single shot directed speech.
* When using this model, the service will stop transcribing audio after the
* first utterance is detected and completed.
*
* When using this model,
* [SEPARATE_RECOGNITION_PER_CHANNEL][google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode.SEPARATE_RECOGNITION_PER_CHANNEL]
* is not supported; multi-channel audio is accepted, but only the first
* channel will be processed and transcribed.
*
* - `telephony`
*
* Best for audio that originated from a phone call (typically recorded at
* an 8khz sampling rate).
*
* - `medical_conversation`
*
* For conversations between a medical provider—for example, a doctor or
* nurse—and a patient. Use this model when both a provider and a patient
* are speaking. Words uttered by each speaker are automatically detected
* and labeled in the returned transcript.
*
* For supported features please see [medical models
* documentation](https://cloud.google.com/speech-to-text/docs/medical-models).
*
* - `medical_dictation`
*
* For dictated notes spoken by a single medical provider—for example, a
* doctor dictating notes about a patient's blood test results.
*
* For supported features please see [medical models
* documentation](https://cloud.google.com/speech-to-text/docs/medical-models).
*
* - `usm`
*
* The next generation of Speech-to-Text models from Google.
* Guidance for choosing which model to use can be found in the [Transcription
* Models
* Documentation](https://cloud.google.com/speech-to-text/v2/docs/transcription-model)
* and the models supported in each region can be found in the [Table Of
* Supported
* Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
* @param string $recognizerLanguageCodesElement The language of the supplied audio as a
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
*
* Supported languages for each model are listed at:
* https://cloud.google.com/speech-to-text/docs/languages
* Supported languages for each model are listed in the [Table of Supported
* Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
*
* If additional languages are provided, recognition result will contain
* recognition in the most likely language detected. The recognition result
Expand Down
53 changes: 8 additions & 45 deletions Speech/samples/V2/SpeechClient/update_recognizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,54 +35,17 @@
* @param string $recognizerModel Which model to use for recognition requests. Select the model
* best suited to your domain to get best results.
*
* Supported models:
*
* - `latest_long`
*
* Best for long form content like media or conversation.
*
* - `latest_short`
*
* Best for short form content like commands or single shot directed speech.
* When using this model, the service will stop transcribing audio after the
* first utterance is detected and completed.
*
* When using this model,
* [SEPARATE_RECOGNITION_PER_CHANNEL][google.cloud.speech.v2.RecognitionFeatures.MultiChannelMode.SEPARATE_RECOGNITION_PER_CHANNEL]
* is not supported; multi-channel audio is accepted, but only the first
* channel will be processed and transcribed.
*
* - `telephony`
*
* Best for audio that originated from a phone call (typically recorded at
* an 8khz sampling rate).
*
* - `medical_conversation`
*
* For conversations between a medical provider—for example, a doctor or
* nurse—and a patient. Use this model when both a provider and a patient
* are speaking. Words uttered by each speaker are automatically detected
* and labeled in the returned transcript.
*
* For supported features please see [medical models
* documentation](https://cloud.google.com/speech-to-text/docs/medical-models).
*
* - `medical_dictation`
*
* For dictated notes spoken by a single medical provider—for example, a
* doctor dictating notes about a patient's blood test results.
*
* For supported features please see [medical models
* documentation](https://cloud.google.com/speech-to-text/docs/medical-models).
*
* - `usm`
*
* The next generation of Speech-to-Text models from Google.
* Guidance for choosing which model to use can be found in the [Transcription
* Models
* Documentation](https://cloud.google.com/speech-to-text/v2/docs/transcription-model)
* and the models supported in each region can be found in the [Table Of
* Supported
* Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
* @param string $recognizerLanguageCodesElement The language of the supplied audio as a
* [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag.
*
* Supported languages for each model are listed at:
* https://cloud.google.com/speech-to-text/docs/languages
* Supported languages for each model are listed in the [Table of Supported
* Models](https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages).
*
* If additional languages are provided, recognition result will contain
* recognition in the most likely language detected. The recognition result
Expand Down
34 changes: 34 additions & 0 deletions Speech/src/V2/BatchRecognizeRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions Speech/src/V2/BatchRecognizeRequest/ProcessingStrategy.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Speech/src/V2/Gapic/SpeechGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ public function __construct(array $options = [])
* The maximum number of files allowed to be specified is 5.
* @type RecognitionOutputConfig $recognitionOutputConfig
* Configuration options for where to output the transcripts of each file.
* @type int $processingStrategy
* Processing strategy to use for this request.
* For allowed values, use constants defined on {@see \Google\Cloud\Speech\V2\BatchRecognizeRequest\ProcessingStrategy}
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
Expand Down Expand Up @@ -637,6 +640,10 @@ public function batchRecognize($recognizer, array $optionalArgs = [])
$request->setRecognitionOutputConfig($optionalArgs['recognitionOutputConfig']);
}

if (isset($optionalArgs['processingStrategy'])) {
$request->setProcessingStrategy($optionalArgs['processingStrategy']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startOperationsCall('BatchRecognize', $optionalArgs, $request, $this->getOperationsClient())->wait();
Expand Down
24 changes: 12 additions & 12 deletions Speech/src/V2/ListCustomClassesRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0ef2434

Please sign in to comment.