felixjunghans / google_speech

Flutter google spech
MIT License
69 stars 41 forks source link

Unhandled Exception: gRPC Error (code: 3, codeName: INVALID_ARGUMENT, message: RecognitionAudio not set., details: [], rawResponse: null, trailers: {endpoint-load-metrics-bin: MeUtLlGZzBBAOdi/XiZLmek/SZ5RcI7ocbo/, grpc-server-stats-bin: AADDdxYDAAAAAA}) #47

Closed DiegoLimeiradaSilva closed 11 months ago

DiegoLimeiradaSilva commented 11 months ago

Describe the bug Unhandled Exception: gRPC Error (code: 3, codeName: INVALID_ARGUMENT, message: RecognitionAudio not set., details: [], rawResponse: null, trailers: {endpoint-load-metrics-bin: MeUtLlGZzBBAOdi/XiZLmek/SZ5RcI7ocbo/, grpc-server-stats-bin: AADDdxYDAAAAAA})

Good morning, it only happens in release mode, in debug normal transcription occurs. can you help me? iOS. Api version v1

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.2 23B92 darwin-arm64, locale en-BR) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] VS Code (version 1.84.2) [✓] Connected device (3 available) [✓] Network resources

Smartphone (please complete the following information):

felixjunghans commented 11 months ago

Can you show me a Code Sample on how you implement it? Also which Version of google_speech do you use?

DiegoLimeiradaSilva commented 11 months ago

Can you show me a Code Sample on how you implement it? Also which Version of google_speech do you use?

google_speech: ^4.3.0

` final Directory tempDir = await getTemporaryDirectory(); final serviceAccount = ServiceAccount.fromString( '${(await rootBundle.loadString('assets/json/root-sanctuary-166417-975d28ba8461.json'))});

                                     final speechToText =
                                          SpeechToText.viaServiceAccount(
                                        serviceAccount,
                                      );
                                      final config = RecognitionConfig(
                                          encoding: AudioEncoding.LINEAR16,
                                          model: RecognitionModel.basic,
                                          enableAutomaticPunctuation: true,
                                          sampleRateHertz: 16000,
                                          languageCode: 'pt-BR');
                                      final streamingConfig =
                                          StreamingRecognitionConfig(
                                              config: config,
                                              interimResults: true);

                                      final audio = File(tempDir.path +
                                              '/' +
                                              _uuid!.toString() +
                                              '.wav')
                                          .readAsBytesSync()
                                          .toList();
                                      final response = await speechToText
                                          .recognize(config, audio);

`

felixjunghans commented 11 months ago

The code looks ok so far. Could you please test whether your audio also contains data in release mode? It should be an array with different numbers.

DiegoLimeiradaSilva commented 11 months ago

I'm going to test, the question can't be the file extension?

DiegoLimeiradaSilva commented 11 months ago

That's right, the array is blank.. Strange that it works in debug.

felixjunghans commented 11 months ago

Ok, then there lies the problem. It looks like there is no audio file where you are looking or the file is empty or cannot be read. Since this is not a problem with google_speech, I would close the issue here.