0

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.

Mangu
  • 3,160
  • 2
  • 25
  • 42
fifa chapman
  • 531
  • 1
  • 4
  • 9

1 Answers1

0

As you said, the link is broken, but, if you look for data logging in Google, you can find how to enroll in data logging.

This will solve the exception in your code.

Mangu
  • 3,160
  • 2
  • 25
  • 42
  • My project is enabled for data logging but I still get the same error. Others [have the same problem currently](https://groups.google.com/forum/#!topic/cloud-speech-discuss/2ORIz02R-9k). – Tim Bunce May 06 '18 at 12:11