jjordanoc / azure_speech_recognition_null_safety

A Flutter plugin that enables interaction with the Azure Cognitive Services Speech-To-Text API
GNU General Public License v3.0
11 stars 14 forks source link

Can't get text directly when run demo #12

Closed wupengbigMarker closed 10 months ago

wupengbigMarker commented 11 months ago

when I ran sample demo and microphone is open, I can't get any text from azure speech callback. Our company registered Azure service for web, I didn't have authority to create a new service for mobile now, so I used key from web directly. Is that related with key? Looking forward to your reply, thank you. @jjordanoc Here is flutter env: [✓] Flutter (Channel stable, 3.16.0, on macOS 14.1 23B74 darwin-x64, locale zh-Hans-CN) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.1) [✓] VS Code (version 1.84.1) [✓] Connected device (4 available) Here is my code:

` initAzure(String token){ _speechAzure = new AzureSpeechRecognition();

// MANDATORY INITIALIZATION
AzureSpeechRecognition.initialize(token, "eastus",lang: "zh-Hans");

_speechAzure?.setFinalTranscription((text) {
  // do what you want with your final transcription
  debugPrint("speech azure:$text");
});

_speechAzure?.setRecognitionStartedHandler(() {
// called at the start of recognition (it could also not be used)
});

_speechAzure?.setRecognitionResultHandler((text) {
  debugPrint("speech recognition result: $text");
  // do what you want with your partial transcription (this one is called every time a word is recognized)
  // if you have a string that is displayed you could call here setState() to updated with the partial result
});

}

Future _recognizeVoice() async { try { AzureSpeechRecognition .simpleVoiceRecognition(); //await platform.invokeMethod('azureVoice'); } on Exception catch (e) { print("Failed to get text '$e'."); } } `