diff --git a/gaktau b/gaktau new file mode 100644 index 0000000..7243df7 --- /dev/null +++ b/gaktau @@ -0,0 +1,48 @@ +package com.blogspot.blogsetyaaji.androidlanjutan; + +import android.content.Intent; +import android.os.Bundle; +import android.speech.RecognizerIntent; +import android.support.v7.app.AppCompatActivity; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import java.util.Locale; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class SttActivity extends AppCompatActivity { + + @BindView(R.id.edTs) + EditText edTs; + @BindView(R.id.btnStt) + Button btnStt; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_stt); + ButterKnife.bind(this); + } + + @OnClick(R.id.btnStt) + public void onViewClicked() { + prosesSuara(); + } + + private void prosesSuara() { + Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,new Locale("in","INA")); + intent.putExtra(RecognizerIntent.EXTRA_PROMPT,"Start Speak"); + + try { + startActivity(intent, ); + }catch (Exception e){ + Toast.makeText(this, getString(R.string.tts_error), Toast.LENGTH_LONG); + } + } +}