I am trying to use the setUseEnhanced
field in the Speech API and I am getting an error like this:
java.util.concurrent.ExecutionException: com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid recognition 'config': Not qualified to request enhanced model. Requires opt-in for logging.
This is the code
// Instantiates a SpeechClient
speech = SpeechClient.create(speechSettings);
GoogleDataCollectionConfig googleDataCollectionConfig = GoogleDataCollectionConfig.newBuilder()
.setLoggingConsentState(LoggingConsentState.ENABLED).build();
RecognitionMetadata recognitionMetadata = RecognitionMetadata.newBuilder()
.setRecordingDeviceType(RecordingDeviceType.SMARTPHONE)
.setInteractionType(InteractionType.PHONE_CALL)
.build();
// Builds the sync recognize request
final RecognitionConfig config = RecognitionConfig.newBuilder()
.setEncoding(AudioEncoding.FLAC)
.setLanguageCode(audioLanguageCode)
.setMaxAlternatives(1)
.setModel("phone_call")
.setGoogleDataCollectionOptIn(googleDataCollectionConfig)
.setUseEnhanced(true)
.setMetadata(recognitionMetadata)
.build();
According to Google docs:
You must opt-in to the audio logging using the instructions in the data logging documentation. If you set useEnhanced to true and you have not enabled audio logging, then you will receive an error.
The link for https://cloud.google.com/speech/data-sharing seems to be broken as well.