• Have Any Question?
  • contact@eitworld.com

Speech to Text





    • “Converting Speech into Text in Android” is a very interesting feature to learn. Google gives its own tool to do so in your app. It’s very easy to convert in text what you speeck. And the tool is RecognizerIntent. Note that the app may not work on emulator but it will properly work on a real device.
    • Create a Button and a TextView in the layout. On clicking the button, the voice will be recorded and it will be shown as text in TextView.
<Button

android:id=”@+id/button”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:onClick=”speak”

android:text=”Press to speak”/>

<TextView

android:id=”@+id/result”

android:layout_below=”@+id/button”

android:layout_width=”wrap_content”

android:layout_height=”wrap_content”

android:text=”You spoke- ” />

 

    • Create the onclick method for the button in .java file. Don’t forget to press Ctrl+Shift+O to import the required packages.
public void speak(View view){

Intent i=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

i.putExtra(RecognizerIntent.EXTRA_LANGUA

 



Real Time Web Analytics