Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Speech] add processing strategy to batch recognition requests #6211

Merged
merged 2 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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