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

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


In  this  blog  the  TTS  is  discussed  as  it  is  always  nice  to  use  TTS  in  android  .  we  just  need  to  follow  few  steps.
  make  a  new  project  with  name  AndroidTextToSpeech  and  a  main  activity  with  the  name  AndroidTextToSpeechActivity.java  and  a  layout  as  main.xml

1)  copy  the  following  code  to  yours  AndroidTextToSpeechActivity.java


import  java.util.Locale;

import  android.app.Activity;
import  android.os.Bundle;
import  android.speech.tts.TextToSpeech;
import  android.util.Log;
import  android.view.View;
import  android.widget.Button;
import  android.widget.EditText;

public  class  AndroidTextToSpeechActivity  extends  Activity  implements
    TextToSpeech.OnInitListener  {
  /**  Called  when  the  activity  is  first  created.  */

  private  TextToSpeech  tts;
  private  Button  btnSpeak;
  private  EditText  txtText;

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

    tts  =  new  TextToSpeech(this,  this);

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

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

    //  button  on  click  event
    btnSpeak.setOnClickListener(new  View.OnClickListener()  {

      public  void  onClick(View  arg0)  {
        speakOut();
      }

    });
  }

  @Override
  public  void  onDestroy()  {
    //  Don't  forget  to  shutdown!
    if  (tts  !=  null)  {
      tts.stop();
      tts.shutdown();
    }
    super.onDestroy();
  }

  public  void  onInit(int  status)  {
    //  TODO  Auto-generated  method  stub

    if  (status  ==  TextToSpeech.SUCCESS)  {

      int  result  =  tts.setLanguage(Locale.US);

      //  tts.setPitch(5);  //  set  pitch  level

      //  tts.setSpeechRate(2);  //  set  speech  speed  rate

      if  (result  ==  TextToSpeech.LANG_MISSING_DATA
          ||  result  ==  TextToSpeech.LANG_NOT_SUPPORTED)  {
        Log.e("TTS",  "oops  it  is  not  supported");
      }  else  {
        btnSpeak.setEnabled(true);
        speakOut();
      }

    }  else  {
      Log.e("TTS",  "Initilization  Failed");
    }

  }

  private  void  speakOut()  {

    String  text  =  txtText.getText().toString();

    tts.speak(text,  TextToSpeech.QUEUE_FLUSH,  null);
  }
}

2)  and  now  in  this  step  you  need  to  make  a  layout  as  follows  at  main.xml


<?xml  version="1.0"  encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="#044372">
      
  <TextView  android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:text="Text  To  Speech  (TTS)"
              android:padding="15dip"
              android:textColor="#ffffff"
              android:textSize="26dip"
              android:gravity="center"
              android:textStyle="bold"/>
  
        <EditText  android:id="@+id/txtText"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="Enter  your  text  here"
                android:layout_marginTop="20dip"              
                android:layout_margin="10dip"/>
      
        <Button  android:id="@+id/btnSpeak"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="Text  to  Speech"
                  android:layout_margin="10dip"/>

</LinearLayout>

3)  run  the  program    at  emulator/device  and  you  can  see  the  output

ÃßõÃßõ : 254 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
1,346
À©µµ¿ì ¼­¹ö 2019 Ãë¾àÁ¡ Á¡°Ë º¸¾È
1,345
À©µµ¿ì ¼­¹ö 2019 Ãë¾àÁ¡ Á¡°Ë º¸¾È (windows server 2019)
1,344
Windows Ãë¾àÁ¡Áø´Ü º¸¾È°¡À̵å¶óÀÎ
1,343
Windows Admin Center¸¦ ÅëÇÑ ¼­¹ö °ü¸®
1,342
À©µµ¿ì ¼­¹ö¿¡¼­ ½ÇÇàµÇ´Â ¼­ºñ½º È®ÀÎ
1,341
Chrome NET::ERR CERT REVOKED ÇØ°á¹æ¹ý
1,340
cmd ¸í·É¾î (¸í·É ÇÁ·ÒÇÁÆ® ¸í·É¾î) ¸ðÀ½
1,339
Windows10 ƯÁ¤ ÇÁ·Î±×·¥(OCS 2007 R2)¿¡¼­ ÷ºÎÆÄÀÏ µå·¡±×¾Øµå·ÓÀÌ ¾È µÇ´Â Çö»ó
1,338
À©µµ¿ì ·Î±×, °ü¸® À̺¥Æ® »èÁ¦
1,337
Ŭ¸° ºÎÆÃ
1,336
Windows ±¸¼º ¿ä¼Ò ÀúÀå¼Ò¿¡¼­ ÆÄÀÏ ¼Õ»ó °Ë»ç
1,335
Windows Defender °Ë»ç ±â·Ï »èÁ¦Çϱâ
1,334
°£´ÜÇÑ À©µµ¿ì 10 Á¤Ç° ÀÎÁõ (Å©·¢ÇÁ·Î±×·¥ ÇÊ¿ä¾øÀ½)
1,333
¿À·ù³­ Æú´õ °­Á¦»èÁ¦ ¹æ¹ý
1,332
Å©·Ò¿¡¼­ Ç÷¡½Ã Ç×»ó Çã¿ëÇϵµ·Ï ¼³Á¤Çϱâ (·¹Áö½ºÆ®¸®) reg ÆÄÀÏ ¸¸µé±â
1,331
GPT µð½ºÅ©¸¦ MBR µð½ºÅ©·Î º¯È¯
1,330
MBR µð½ºÅ©¸¦ GPT µð½ºÅ©·Î º¯È¯
1,329
±¸±Û °Ë»öÀ» 200% È°¿ëÇÏ°Ô ÇØÁÖ´Â °Ë»ö ¸í·É¾î ÃÑÁ¤¸®
1,328
[Jquery] jQuery·Î ¿ìŬ¸¯ ¹æÁö, µå·¡±× ¹æÁö, ¼±Åà ¹æÁö (IE10, ÆÄÀ̾îÆø½º, Å©·Ò È®ÀÎ)
1,327
php »ç¿ëÀÚ Á¢¼ÓIP, ºê¶ó¿ìÀúÁ¤º¸, osÁ¤º¸, http, https Á¢¼ÓÇÁ·ÎÅäÄÝ ¾Ë¾Æ¿À±â
1,326
[PHP] IE ºê¶ó¿ìÀú Á¢¼Ó °ËÃâÇϱâ
1,325
À©µµ¿ì10 ½Ã½ºÅÛ ¿¹¾à ÆÄƼ¼Ç È®ÀÎ ¹× »èÁ¦
1,324
À©µµ¿ì10 º¹±¸ ÆÄƼ¼Ç »èÁ¦ ¹æ¹ý
1,323
À©µµ¿ì10 ºÎÆÃÁö¿¬ °ËÀºÈ­¸é¿¡¼­ ¸îºÐ°£ ¸Ó¹«´Â Çö»ó ÇØ°á¹æ¹ý
1,322
»ï¼º³ëÆ®ºÏ ¹ÙÀÌ¿À½º ÁøÀÔÀÌ ºÒ°¡´ÉÇÑ °æ¿ì ¹ÙÀÌ¿À½º À缳ġ¿Í NVRAM ÃʱâÈ­
1,321
ÀͽºÇ÷η¯(IE)ÀÇ ±¸±Û °Ë»ö°ø±ÞÀÚ Çѱ۷Πº¯°æ ¹æ¹ý
1,320
À©µµ¿ì 10 ±âº» ¾Û »èÁ¦ ¹× º¹±¸
1,319
meta ÅÂ±× http-equiv ¼³Á¤¹æ¹ý°ú Â÷ÀÌÁ¡
1,318
±¸±Û(Google)°Ë»ö¿¡¼­ °í±Þ¿¬»êÀÚ¸¦ ÀÌ¿ëÇÏ¿© ¸¹Àº Á¤º¸¸¦ ¾ò´Â ¹æ¹ý
1,317
ÇÁ·Î±×·¥ ¾øÀÌ Çϵåµð½ºÅ© º¹»ç ¹× ¹é¾÷Çϱâ
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.