Flutter Speech to Text in Arabic Language - flutter

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.

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,
);

Related

text to speech arabic in flutter

I am searching for Text to speech package in flutter and I found this one flutter_tts
but its not supporting Arabic language is there any way to Add Arabic language or any other package that Supports Arabic language ?
Use Flutter speech_to_text package.
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,
);

How to handle auto direction of text with dart-flutter?

I need to make auto-detection for posts language to change the text direction according to language, I Used 'firebase_mlkit_language.dart' to make the auto-detection of language.
this is a screenshot of screen:
I need the English post alignment to be from ltr.
this Function I made to check lang
Future<String> checkLang(String text)async{
final LanguageIdentifier languageIdentifier = FirebaseLanguage.instance.languageIdentifier();
final List<LanguageLabel> labels = await languageIdentifier.processText(text);
for (LanguageLabel label in labels) {
final String text = label.languageCode;
final double confidence = label.confidence;
}
return labels[0].languageCode;
}
while getposts function is processing and get the posts from firebase, I added this line to get a list of posts language
postsLang.add(checkLang(PostModel.fromJson(element.data()).text).toString());
then while generating the posts UI, in the post widget i made this condition to check whether the language is Arabic 'ar'
so, the direction should be from right to left.
textDirection: AppCubit.get(context).postsLang[index].toString() == 'ar' ?TextDirection.rtl:TextDirection.ltr,

Gujrati font Rendering problem in Flutter PDF

I am Developing a Mobile application using Flutter 2.0, this whole application is in the Gujarati language, the application is ready, all text is rendering perfectly in the app, but when I generate pdf from data that are on the screen, the Gujarati fonts not rendering correctly,
I am using plugin
pdf: ^3.0.1
for Ex,
there is the string on-screen is લોગિન
and when I print in pdf it becomes લોગનિ
Same for another ઉત્સવ becomes ઉત્ સવ(ignore space between words)
Use this flutter library
https://pub.dev/packages/syncfusion_flutter_pdf#create-a-pdf-document-from-simple-text
//Create a new PDF document.
final PdfDocument document = PdfDocument();
//Read font data.
final Uint8List fontData = File('arial.ttf').readAsBytesSync();
//Create a PDF true type font object.
final PdfFont font = PdfTrueTypeFont(fontData, 12);
//Draw text using ttf font.
document.pages.add().graphics.drawString('Hello World!!!', font,
bounds: const Rect.fromLTWH(0, 0, 200, 50));
// Save the document.
File('TrueType.pdf').writeAsBytes(document.save());
// Dispose the document.
document.dispose();

Flutter: Text to Voice Tamil language is support?

I have trying to convey my text to speech tamil language but it not support any other way is there?
Am using : flutter_tts package
my code:
speak() async {
final languages = await Tts.getAvailableLanguages();
var isGoodLanguage = await Tts.isLanguageAvailable("ta");
print(isGoodLanguage);
await Tts.setLanguage("tamil");
Tts.speak('வாழ்ந்த காலம்: 2 ஆம் நூறாண்டு முதல் 8 நூற்றாண்டு வரை'); }
But it's not working anyone tried with tamil text to voice please help me. Thanks.
If "ta" is a supported language code on your device (You should receive the list of supported language codes when you run await Tts.getAvailableLanguages()), you should use that to set the language rather than "tamil".
Change: await Tts.setLanguage("tamil");
To: await Tts.setLanguage("ta");

iText support for HIndi and Arabic

Our project needs dynamic PDF generation in 6 languages which consists of Hindi and Arabic. iText works brilliantly for other languages except these two. Can someone let me know if current version of iText(5.5.5) have ligature implementation for Hindi and Arabic?
about Arabic language:
I understand you face one of two problems:
the Arabic words don't appear.
the Arabic words appears like :
the solution is:
first: update your itext 5.5.8 to itext 7 implementation:
https://search.maven.org/artifact/com.itextpdf/itext7-core/7.2.2/pom
then edit your code:
String font = "your Arabic font";
PdfFontFactory.register(font);
FontProgram fontProgram = FontProgramFactory.createFont(font, true);
PdfFont f = PdfFontFactory.createFont(fontProgram, PdfEncodings.IDENTITY_H);
LanguageProcessor languageProcessor = new ArabicLigaturizer();
com.itextpdf.kernel.pdf.PdfDocument tempPdfDoc = new
com.itextpdf.kernel.pdf.PdfDocument(new PdfReader(pdfFile.getPath()), TempWriter);
com.itextpdf.layout.Document TempDoc = new
com.itextpdf.layout.Document(tempPdfDoc);
com.itextpdf.layout.element.Paragraph paragraph0 = new
com.itextpdf.layout.element.Paragraph(languageProcessor.process("الاستماره الالكترونية"))
.setFont(f).setBaseDirection(BaseDirection.RIGHT_TO_LEFT)
.setFontSize(15);
//and look how i useded setBaseDirection & and don't use TextAlignment ,it will work without it