‫Hello, my friends.
‫After we have created successfully that layout and have added the dependencies for our project here,
‫the Elk Kit, Dexter Recognition and the Glide.
‫Now let's add some functionality to the main activity.
‫So let's start by initializing the widgets.
‫Widgets,
‫image view, image view, text view, text view, plus enter to import the package and the class.
‫And we have text recognizer or the widgets, the button button choose.
‫The image and the speech
‫between here and speech 18.
‫Plus enter to import the class.
‫Now, the variables that we need to use inside this project, we need an input input image which is
‫from Google M Kit, MLK Dot vision.
‫Come on, it's called input image.
‫We need a text recognizer, which is from the vision text recognizer and we need here text to speech.
‫Text to speech.
‫It's called T text to speech
‫and we need a bitmap.
‫So that map.
‫Text image plus enter.
‫And it's important.
‫Now let's initialize these widgets and variable and let's start adding that the functionalities of this
‫application so recognizer equal to text recognizer or text recognition which is from the ML kit text
‫recognition get client text recognizer option text recognizer option dot default options we load.
‫We are loading the default options image button equal find view by ID or the ID dot image.
‫Or choose image.
‫The second one is the image view.
‫Equal find view by ID that ID dot image of you.
‫The third one is called text view equal to find view by ID that ID dot text or what is the name of the
‫text view that we have created?
‫I will go to the main activity and it's called text.
‫So here it is named as text and the speech button equal find VBA IDR that ID dot speech.
‫So these are our which so image button dot set on click listener new or click listener.
‫We are choosing an image.
‫So what we are going to do, we are going to call a method called open gallery.
‫So this this method will open the gallery in order to allow the user to choose from the gallery and
‫image to translate its its text, so create it inside the main activity.
‫So here we have the open gallery method that we are going to fill later on in the next video.
‫Now let's add some functionalities also.
‫So T or text text to speech, equal view, text to speech get application context and the new text to
‫speech new.
‫Text to speech dot
‫on.
‫Initiate a lesson.
‫What we are going to make is implementing the method on initiate.
‫So this initiate, if I does not equal to text to speech dot error, then what to do?
‫We are going to make that text to speech
‫the set language to local thought you s okay.
‫This is the locale import the class.
‫We are setting it for us.
‫You can develop this project in order to allow the user to select what language he want.
‫So you can see how to select and add the languages and the languages packages and the translation from
‫the previous project, which is translation app.
‫So you can combine all of this project in one big app and it's become a huge app.
‫But I should remember you that you need to pay attention about every detail, every single detail,
‫because any, any error inside these algorithms and these codes would make a crash a non or a stop or
‫application not responding and ask for your application.
‫So please pay attention and be careful when making these logic.
‫Till now I simplified this application as much as I can, so I put the language by default as us so
‫you can make it complex by selecting the user, allowing the user to select what the what language or
‫you can detect any language.
‫What is the language that he is scanning?
‫So this is how you can go bigger and bigger with with your application and your logic.
‫Now the speech between set and click listener new view on Click Listener to text to speech dot speak.
‫We are going to allow the user to listen for the translated and or the scanned OCR text if you don't.
‫Get text.
‫Don't.
‫To string.
‫The second parameter is texting text to speech dot, cue flash and none.
‫Okay, so these are the parameters.
‫Okay.
‫So.
‫This is what we have done inside the create method.
‫And the next video, we are going to continue with these methods and add the own activity result and
‫open gallery method.