ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î

Android Speech To Text
7³â Àü
http://upadhyayjiteshandroid.blogspot.kr/2013/01/android-speech-to-text.html


make  a  project  with  name  SpeechToTextDemo  and  a  main  activity  with  the  name  MainActivity  and  copy  the  following  code  to  it


import  java.util.ArrayList;

import  android.app.Activity;
import  android.content.ActivityNotFoundException;
import  android.content.Intent;
import  android.os.Bundle;
import  android.speech.RecognizerIntent;
import  android.view.Menu;
import  android.view.View;
import  android.widget.ImageButton;
import  android.widget.TextView;
import  android.widget.Toast;

public  class  MainActivity  extends  Activity  {

  protected  static  final  int  RESULT_SPEECH  =  1;

  private  ImageButton  btnSpeak;
  private  TextView  txtText;

  @Override
  public  void  onCreate(Bundle  savedInstanceState)  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    txtText  =  (TextView)  findViewById(R.id.txtText);

    btnSpeak  =  (ImageButton)  findViewById(R.id.btnSpeak);

    btnSpeak.setOnClickListener(new  View.OnClickListener()  {

      public  void  onClick(View  v)  {

        Intent  intent  =  new  Intent(
            RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,  "en-US");

        try  {
          startActivityForResult(intent,  RESULT_SPEECH);
          txtText.setText("i  love  you");
        }  catch  (ActivityNotFoundException  a)  {
          Toast  t  =  Toast.makeText(getApplicationContext(),
              "Ops!  Your  device  doesn't  support  Speech  to  Text",
              Toast.LENGTH_SHORT);
          t.show();
        }
      }
    });

  }

  @Override
  public  boolean  onCreateOptionsMenu(Menu  menu)  {
    getMenuInflater().inflate(R.menu.activity_main,  menu);
    return  true;
  }

  @Override
  protected  void  onActivityResult(int  requestCode,  int  resultCode,  Intent  data)  {
    super.onActivityResult(requestCode,  resultCode,  data);

    switch  (requestCode)  {
    case  RESULT_SPEECH:  {
      if  (resultCode  ==  RESULT_OK  &&  null  !=  data)  {

        ArrayList<String>  text  =  data
            .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

        txtText.setText(text.get(0));
      }
      break;
    }

    }
  }
}

activity_main.xml  is  the  layout  where  you  need  to  copy  the  following  layout  to  it

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/textView1"
        android:layout_toLeftOf="@+id/textView1"
        android:gravity="center"
        android:orientation="vertical"  >

        <ImageButton
                android:id="@+id/btnSpeak"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:contentDescription="@string/speak"
                android:src="@android:drawable/ic_btn_speak_now"  />

        <TextView
                android:id="@+id/txtText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:textAppearance="?android:attr/textAppearanceLarge"  />

</LinearLayout>
ÃßõÃßõ : 256 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
217
MediaPlayer Ŭ·¡½º »ç¿ë¹ý
216
¾Èµå·ÎÀ̵忡¼­ audio player ½ÇÇàÇϱâ
215
[Android] MediaPlayer À½¾ÇÀç»ý±â ¸¸µé±â
214
Eclipse¿Í Android NDK ¿¬µ¿Çϱâ
213
Android Sliding Drawer Functionality ¾Èµå·ÎÀÌµå ½½¶óÀ̵ù µå·Î¿ì ¿¹Á¦ sample
Android Speech To Text
211
Android WebPageLoader with progress-bar
210
Android Text To Speech(TTS)
209
Android Playing Audio from a web url
208
Button height different from background height in Android image design
207
Android Getting Started with Material Design
206
Using toast inside timertask perfect
205
³×Æ®¿öÅ© »óÅ [Android]
204
Webview source [Android]
203
°øÀ¯ Intent [Android]
202
intent uri ¸ðÀ½ [Android]
201
http requestWebViewClient [Android]
200
ij½Ã »èÁ¦
199
ij½Ã Áö¿ì±â [Android]
198
¹Ù·ÎÇ®¾î(¼öÇÐ ¹®Á¦ ÁúÀÇÀÀ´ä SNS) ¿¡ »ç¿ëµÈ ¿ÀǼҽº ¶óÀ̺귯¸® [Android]
197
Webviw [Android]
196
¿ÀǼҽº ¶óÀ̺귯¸® ¸ðÀ½ [Android]
195
Android webview °³¹ß½Ã ¾Ë¾ÆµÖ¾ß ÇÒ °Íµé [Android]
194
webview µ¿¿µ»ó Àç»ý [Android]
193
[Android] Webview 404 ¿¡·¯ ó¸®
192
[Android] webview ssl ¹®Á¦
191
[Android] Webview url ¼û±â±â
190
[Android] AlarmManager ÀÏÁ¤½Ã°£ À̺¥Æ® ½ÇÇà
189
¾Èµå·ÎÀÌµå ¿ÀǼҽº ³¡ÆÇ
188
android studio DefaultHttpClient, HttpClient import ¿¡·¯
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.