title: How to execute Python codes from Java code in Android Studio?
body: <p>I am building an Android application in Android studio with Java. I want to use Speech to text and Text to speech and some Machine Learning based python programs that I had already written.
  Is it possible to do this? What is the technology stack that I need to accomplish this?</p>
  
  <p>I came across various solutions like using sl4A, Jython, QPython and running the python code on the server.I have also gone through the following but I haven't found a solution yet</p>
  
  <p><a href="https://stackoverflow.com/questions/34235763/execute-python-script-from-android-app-in-java">Execute python script from android App in Java</a></p>
  
  <p><a href="https://stackoverflow.com/questions/28917832/how-to-execute-python-script-from-java-code-in-android">How to execute Python script from Java code in Android</a></p>
  
  <p><a href="https://stackoverflow.com/questions/34235763/execute-python-script-from-android-app-in-java">Execute python script from android App in Java</a></p>
  
  <p>Please explain with an example. As an example if I want to use the following python code (Speech to Text conversion using Google Speech recognition API) to run in my android app:</p>
  
  <pre><code>import speech_recognition as sr
  r = sr.Recognizer()
  
  with sr.Microphone() as src:
      print("speak....")
      audio = r.listen(src, 2)
      print("over")
  try:
      print("you said: "+r.recognize_google(audio))
  except:
      print("cannot recognize")
  </code></pre>
  
  <p>What steps am I supposed to follow? What is the best way to achieve it?
  Thank you in advance.</p>
  
  <p>EDIT 1: Can it be achieved using <strong>azure services</strong>?</p>