Hello Google Cloud Speech-to-Text community,
I hope this message finds you well. I am currently working on a Java client application that utilizes the Speech-to-Text streaming recognition functionality provided by the Google Cloud SDK. The overall functionality is working smoothly; however, I have encountered an issue when attempting to integrate custom classes into the recognition process.
I am facing an "io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Custom classes need at least one item" error at runtime, even though I have configured and verified the presence of items within the custom class "leikaiwei" through the Google Cloud Console.
Here's a snippet of the relevant code:
Hello Google Cloud Speech-to-Text community,
I hope this message finds you well. I am currently working on a Java client application that utilizes the Speech-to-Text streaming recognition functionality provided by the Google Cloud SDK. The overall functionality is working smoothly; however, I have encountered an issue when attempting to integrate custom classes into the recognition process.
I am facing an "io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Custom classes need at least one item" error at runtime, even though I have configured and verified the presence of items within the custom class "leikaiwei" through the Google Cloud Console.
Here's a snippet of the relevant code:
```java
// Code snippet
ClientStream<StreamingRecognizeRequest> clientStream = speechClient.streamingRecognizeCallable().splitCall(responseObserver);
RecognitionConfig.Builder recognitionConfigBuilder = RecognitionConfig.newBuilder()
.setEncoding(RecognitionConfig.AudioEncoding.LINEAR16)
.setLanguageCode(config.getLanguageCode())
.setModel("command_and_search")
.setSampleRateHertz(16000);
if (Phrases.size() > 0) {
recognitionConfigBuilder.addSpeechContexts(0, SpeechContext.newBuilder()
.addAllPhrases(instance.Phrases)
.build());
}
if (true) {
recognitionConfigBuilder.setAdaptation(
SpeechAdaptation.newBuilder().addCustomClasses(
CustomClass.newBuilder()
.setCustomClassId("leikaiwei")
.setName("projects/787011263872/locations/global/customClasses/leikaiwei")
.build()
).build()
);
}
RecognitionConfig recognitionConfig = recognitionConfigBuilder.build();
Despite having items in the "leikaiwei" custom class, I'm encountering the mentioned runtime error. I have verified the configuration in the Google Cloud Console, and everything seems correct.
Any assistance or guidance on resolving this issue would be greatly appreciated. If you have any insights into potential misconfigurations or if there's something specific I need to adjust in the code, please let me know.
Thank you in advance for your support!
Best regards,
Laynex