Search code examples
pythonandroidpyaudio

Is there any way to get microphone input on Android using Python?


I want to make an App using kivy and speechrecognition, so i ineed to get mic input. PyAudio doesn't support Android, and I have tried using audiostream, but that also doesn't seem to work. Can I somehow get audio input using Python on an Android device?


Solution

  • You can use Kivy to write Android apps in Python.

    Android provides an audio interface described here for Java/Kotlin.

    The directions of how to wrap Android Java APIs using Pyjinius in Kivy is here.

    You also could also use Plyer. As documented here the code would look something like:

    from plyer.facades import Audio
    
    Audio.start() # starts recording
    
    Audio.stop() # stops recording
    
    Audio.play() # plays recording