Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
feat: Support output transcript to GCS for LongRunningRecognize (#467)
Browse files Browse the repository at this point in the history
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/fafdc5bd-5ed6-41ca-a975-45f17b90ee7f/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 362294447
Source-Link: googleapis/googleapis@b6ebac1
  • Loading branch information
yoshi-automation committed Mar 16, 2021
1 parent 748dd18 commit 5ad0d36
Show file tree
Hide file tree
Showing 23 changed files with 1,654 additions and 401 deletions.
Expand Up @@ -30,6 +30,7 @@
import com.google.cloud.speech.v1p1beta1.stub.AdaptationStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -496,6 +497,35 @@ public final UnaryCallable<ListPhraseSetRequest, ListPhraseSetResponse> listPhra
return stub.listPhraseSetCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Update a phrase set.
*
* <p>Sample code:
*
* <pre>{@code
* try (AdaptationClient adaptationClient = AdaptationClient.create()) {
* PhraseSet phraseSet = PhraseSet.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* PhraseSet response = adaptationClient.updatePhraseSet(phraseSet, updateMask);
* }
* }</pre>
*
* @param phraseSet Required. The phrase set to update.
* <p>The phrase set's `name` field is used to identify the set to be updated. Format:
* {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set}
* @param updateMask The list of fields to be updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final PhraseSet updatePhraseSet(PhraseSet phraseSet, FieldMask updateMask) {
UpdatePhraseSetRequest request =
UpdatePhraseSetRequest.newBuilder()
.setPhraseSet(phraseSet)
.setUpdateMask(updateMask)
.build();
return updatePhraseSet(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Update a phrase set.
Expand Down Expand Up @@ -977,6 +1007,35 @@ public final ListCustomClassesPagedResponse listCustomClasses(ListCustomClassesR
return stub.listCustomClassesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Update a custom class.
*
* <p>Sample code:
*
* <pre>{@code
* try (AdaptationClient adaptationClient = AdaptationClient.create()) {
* CustomClass customClass = CustomClass.newBuilder().build();
* FieldMask updateMask = FieldMask.newBuilder().build();
* CustomClass response = adaptationClient.updateCustomClass(customClass, updateMask);
* }
* }</pre>
*
* @param customClass Required. The custom class to update.
* <p>The custom class's `name` field is used to identify the custom class to be updated.
* Format: {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class}
* @param updateMask The list of fields to be updated.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final CustomClass updateCustomClass(CustomClass customClass, FieldMask updateMask) {
UpdateCustomClassRequest request =
UpdateCustomClassRequest.newBuilder()
.setCustomClass(customClass)
.setUpdateMask(updateMask)
.build();
return updateCustomClass(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Update a custom class.
Expand Down
Expand Up @@ -273,6 +273,7 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
* LongRunningRecognizeRequest.newBuilder()
* .setConfig(RecognitionConfig.newBuilder().build())
* .setAudio(RecognitionAudio.newBuilder().build())
* .setOutputConfig(TranscriptOutputConfig.newBuilder().build())
* .build();
* LongRunningRecognizeResponse response = speechClient.longRunningRecognizeAsync(request).get();
* }
Expand Down Expand Up @@ -301,6 +302,7 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
* LongRunningRecognizeRequest.newBuilder()
* .setConfig(RecognitionConfig.newBuilder().build())
* .setAudio(RecognitionAudio.newBuilder().build())
* .setOutputConfig(TranscriptOutputConfig.newBuilder().build())
* .build();
* OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> future =
* speechClient.longRunningRecognizeOperationCallable().futureCall(request);
Expand Down Expand Up @@ -330,6 +332,7 @@ public final UnaryCallable<RecognizeRequest, RecognizeResponse> recognizeCallabl
* LongRunningRecognizeRequest.newBuilder()
* .setConfig(RecognitionConfig.newBuilder().build())
* .setAudio(RecognitionAudio.newBuilder().build())
* .setOutputConfig(TranscriptOutputConfig.newBuilder().build())
* .build();
* ApiFuture<Operation> future = speechClient.longRunningRecognizeCallable().futureCall(request);
* // Do something.
Expand Down
Expand Up @@ -53,10 +53,10 @@
"methods": ["listPhraseSet", "listPhraseSet", "listPhraseSet", "listPhraseSetPagedCallable", "listPhraseSetCallable"]
},
"UpdateCustomClass": {
"methods": ["updateCustomClass", "updateCustomClassCallable"]
"methods": ["updateCustomClass", "updateCustomClass", "updateCustomClassCallable"]
},
"UpdatePhraseSet": {
"methods": ["updatePhraseSet", "updatePhraseSetCallable"]
"methods": ["updatePhraseSet", "updatePhraseSet", "updatePhraseSetCallable"]
}
}
}
Expand Down
Expand Up @@ -352,21 +352,18 @@ public void updatePhraseSetTest() throws Exception {
.build();
mockAdaptation.addResponse(expectedResponse);

UpdatePhraseSetRequest request =
UpdatePhraseSetRequest.newBuilder()
.setPhraseSet(PhraseSet.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
PhraseSet phraseSet = PhraseSet.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

PhraseSet actualResponse = client.updatePhraseSet(request);
PhraseSet actualResponse = client.updatePhraseSet(phraseSet, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdatePhraseSetRequest actualRequest = ((UpdatePhraseSetRequest) actualRequests.get(0));

Assert.assertEquals(request.getPhraseSet(), actualRequest.getPhraseSet());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertEquals(phraseSet, actualRequest.getPhraseSet());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -379,12 +376,9 @@ public void updatePhraseSetExceptionTest() throws Exception {
mockAdaptation.addException(exception);

try {
UpdatePhraseSetRequest request =
UpdatePhraseSetRequest.newBuilder()
.setPhraseSet(PhraseSet.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
client.updatePhraseSet(request);
PhraseSet phraseSet = PhraseSet.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updatePhraseSet(phraseSet, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
Expand Down Expand Up @@ -729,21 +723,18 @@ public void updateCustomClassTest() throws Exception {
.build();
mockAdaptation.addResponse(expectedResponse);

UpdateCustomClassRequest request =
UpdateCustomClassRequest.newBuilder()
.setCustomClass(CustomClass.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
CustomClass customClass = CustomClass.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

CustomClass actualResponse = client.updateCustomClass(request);
CustomClass actualResponse = client.updateCustomClass(customClass, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockAdaptation.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateCustomClassRequest actualRequest = ((UpdateCustomClassRequest) actualRequests.get(0));

Assert.assertEquals(request.getCustomClass(), actualRequest.getCustomClass());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertEquals(customClass, actualRequest.getCustomClass());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -756,12 +747,9 @@ public void updateCustomClassExceptionTest() throws Exception {
mockAdaptation.addException(exception);

try {
UpdateCustomClassRequest request =
UpdateCustomClassRequest.newBuilder()
.setCustomClass(CustomClass.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
client.updateCustomClass(request);
CustomClass customClass = CustomClass.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateCustomClass(customClass, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
Expand Down
Expand Up @@ -267,8 +267,8 @@ public com.google.protobuf.TimestampOrBuilder getLastUpdateTimeOrBuilder() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -291,8 +291,8 @@ public java.lang.String getUri() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand Down Expand Up @@ -1131,8 +1131,8 @@ public com.google.protobuf.TimestampOrBuilder getLastUpdateTimeOrBuilder() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -1154,8 +1154,8 @@ public java.lang.String getUri() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -1177,8 +1177,8 @@ public com.google.protobuf.ByteString getUriBytes() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -1199,8 +1199,8 @@ public Builder setUri(java.lang.String value) {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -1217,8 +1217,8 @@ public Builder clearUri() {
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand Down
Expand Up @@ -111,8 +111,8 @@ public interface LongRunningRecognizeMetadataOrBuilder
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand All @@ -124,8 +124,8 @@ public interface LongRunningRecognizeMetadataOrBuilder
*
*
* <pre>
* Output only. The URI of the audio file being transcribed. Empty if the
* audio was sent as byte content.
* Output only. The URI of the audio file being transcribed. Empty if the audio was sent
* as byte content.
* </pre>
*
* <code>string uri = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
Expand Down

0 comments on commit 5ad0d36

Please sign in to comment.