sm 66
sm 66

Reputation: 191

Flutter Speech to Text in Arabic Language

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

Answers (2)

reda bouziani
reda bouziani

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

user16930239
user16930239

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

Related Questions