title: How to implement speech-to-text in a grid view
body: <p>I am trying to implement speech to text in a grid view in order to execute some commands. The grid view is made of cells and I am trying to enable the speech to text on each of these cells.
  I have the code for this, but I wasn't able to add it in this grid view that I have, because I don't know how to connect it to the base adapter.</p>
  <p>Here is the first part of the code:</p>
  <pre><code>        cellgrid.adapter = cellAdapter
  
          onClickMic()
  
          textToSpeech = TextToSpeech(applicationContext) { i -&gt;
              if (i != TextToSpeech.ERROR) {
                  textToSpeech!!.language = Locale.US
              }
          }
  </code></pre>
  <p>Here is the second part of the code:</p>
  <pre><code>   private fun onClickMic() {
         val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
         intent.putExtra(
             RecognizerIntent.EXTRA_LANGUAGE_MODEL,
             RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
         )
         intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.US)
         startActivityForResult(intent, 10)
     }
  
  
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
         super.onActivityResult(requestCode, resultCode, data)
         if (resultCode == RESULT_OK &amp;&amp; data != null) {
             when (requestCode) {
                 10 -&gt; {
                     val text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
                     textCommand(text!![0])
                 }
             }
         }
     }
  
     private fun textCommand(text: String?) {
         val starttv: TextView = findViewById(R.id.starttv)
         when (text){
             &quot;I&quot; -&gt; starttv.visibility = View.GONE
  
         }
     }
  </code></pre>
  <p>I want to be able to implement this on each cell, <strong>inside the grid view</strong>, not outside of it.
  Any thoughts on this?</p>