title: Speech to text and language translation app(I want you to listen to me at regular intervals)
body: <p>I did a speech to text application.  At the same time language translation application is doing. After talking to the application I want to listen to me at regular intervals.What should I do for it?I share of the code applications.Thanks.</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  protected static final int RESULT_SPEECH = 1;
  TextView output;
  EditText input;
  
  ImageButton speak;
  String out;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      input = (EditText) findViewById(R.id.InputText);
      output = (TextView) findViewById(R.id.OutputText);
      speak = (ImageButton) findViewById(R.id.SpeakButton);
      speak.setOnClickListener(new View.OnClickListener() {
  
          @Override
          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);
                  input.setText("");
              } catch (ActivityNotFoundException a) {
                  Toast.makeText(getApplicationContext(), "Olmadı.",
                          Toast.LENGTH_SHORT).show();
              }
  
          }
  
      });
  
  
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p><strong>METHODS:</strong></p>
  
  <pre><code>protected void onActivityResult(int requestCode,int resultCode,Intent data){
      super.onActivityResult(requestCode,resultCode,data);
      while(requestCode == RESULT_SPEECH)
      {
          if(resultCode == RESULT_OK &amp;&amp; null != data )
          {
              ArrayList&lt;String&gt; text = data
                      .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
  
              input.setText(text.get(0));
              Log.d("deneme", text.toString());
              Log.d("deneme12",data.toString());
          }
          break;
      }
  
              new AsyncCaller().execute();
  
  
  }
  
  private class AsyncCaller extends AsyncTask&lt;Void,Void,Void&gt; {
  
      protected void onPreExecute() {
  
      }
      @Override
      protected Void doInBackground(Void... params) {
          try {
              out = translate(input.getText().toString());
          } catch (IOException e) {
              e.printStackTrace();
              Log.e("Hata",e.getLocalizedMessage());
          }
          return null;
      }
      protected void onPostExecute(Void result) {
          output.setText(out);
      }
  
  }
  
  public static String translate(String text) throws IOException {
  
      URL url = new URL(
              "http://translate.google.com.tw/translate_a/t?client=t&amp;hl=en&amp;sl=tr&amp;tl=en&amp;ie=UTF-8&amp;oe=UTF-8&amp;multires=1&amp;oc=1&amp;otf=2&amp;ssel=0&amp;tsel=0&amp;sc=1&amp;q="
                      + URLEncoder.encode(text, "UTF-8"));
      URLConnection urlConnection = url.openConnection();
      urlConnection.setRequestProperty("User-Agent", "Something Else");
      BufferedReader br = new BufferedReader(new InputStreamReader(
              urlConnection.getInputStream()));
      String result = br.readLine();
      br.close();
  
      result = result.substring(2, result.indexOf("]]") + 1);
      StringBuilder sb = new StringBuilder();
      String[] splits = result.split("(?&lt;!\\\\)\"");
      for (int i = 1; i &lt; splits.length; i += 8)
          sb.append(splits[i]);
      return sb.toString().replace("\\n", "\n").replaceAll("\\\\(.)", "$1");
  }
  </code></pre>