Reputation: 191
Is there is a way to convert speech into text using flutter (specially if the the speech in Arabic and also I want the resulted text in Arabic) I've found many resources that explains how speech to text in English but not Arabic so I hope anyone can help me.
Upvotes: 2
Views: 2919
Reputation: 1
var locales = await speech.locales();
this line gives you list of localNames (languages) if the language that you need is not include in this list you can add it, for example i will add Algerian arabic language :
locals.add(LocaleName('ar_DZ', 'العربية (الجزائر)'));
or you can fix the language in SpeechToText.listen
function:
speech.listen(
onResult: resultListener,
listenFor: Duration(seconds: listenFor ?? 30),
pauseFor: Duration(seconds: pauseFor ?? 3),
localeId: 'ar_DZ',
onSoundLevelChange: soundLevelListener,
listenOptions: options,
);
Upvotes: 0
Reputation: 9735
Use Flutter speech_to_text library.
to change language, localeId = the ID of the Arabic language on this device:
var locales = await speech.locales();
// Some UI or other code to select a locale from the list
// resulting in an index, selectedLocale
var selectedLocale = locales[selectedLocale];
speech.listen(
onResult: resultListener,
localeId: selectedLocale.localeId,
);
Upvotes: 1