I am utilizing a flutter package deal that make a request to the google speech to textual content api named gcloud_speech, right here is the package deal https://pub.dev/packages/google_speech
the accuracy of the speech to textual content is nice on IOS however unhealthy on android
right here is my code
void recognise() async {
if (mounted) {
setState(() {
recognizing = true;
});
}
ultimate audioTranscripts = speechTextProvider.getTransctipts(widget.audio);
if (audioTranscripts != null) {
textual content = audioTranscripts;
} else {
ultimate serviceAccount = ServiceAccount.fromString(
'${(await rootBundle.loadString('belongings/json/speakbit-23921-66819b1b8fcc.json'))}');
ultimate speechToText = SpeechToTextBeta.viaServiceAccount(serviceAccount);
ultimate config = _getConfig();
ultimate audio = await _getAudioContent(widget.audio);
await speechToText.acknowledge(config, audio).then((worth) {
if (mounted) {
setState(() {
textual content = worth.outcomes
.map((e) => e.options.first.transcript)
.be a part of('n');
speechTextProvider.saveTranscripts(textual content, widget.audio);
print('that is the textual content $textual content');
});
}
});
}
if (mounted) {
setState(() {
recognizeFinished = true;
recognizing = false;
});
}
}
RecognitionConfigBeta _getConfig() => RecognitionConfigBeta(
audioChannelCount: 1,
encoding: Platform.isIOS? AudioEncoding.LINEAR16:AudioEncoding.FLAC ,
mannequin: RecognitionModel.fundamental,
enableAutomaticPunctuation: true,
sampleRateHertz: 16000,
languageCode: 'en-US');
Future<Listing> _getAudioContent(String title) async {
return File(title).readAsBytesSync().toList();
}