Question

Is it Possible to record Audio in Kivy yet ?

I understand from documentation that there is a way to play audio but Can we record voice and then can play it ? and do it work on all platforms ? I mean can we develop on Windows or Ubuntu and run app on Android ?

If not may be any work around to do it ?

Was it helpful?

Solution

you can try this recipe for kivy

https://github.com/kivy/audiostream

it is an official recipe Kivy then can solve your problem.

OTHER TIPS

I was not able to find any other way than a platform specific way. I ended up using a variation of this on Android:

from jnius import autoclass
from time import sleep

if platform() == 'android':
    # get the needed Java classes
    MediaRecorder = autoclass('android.media.MediaRecorder')
    AudioSource = autoclass('android.media.MediaRecorder$AudioSource')
    OutputFormat = autoclass('android.media.MediaRecorder$OutputFormat')
    AudioEncoder = autoclass('android.media.MediaRecorder$AudioEncoder')

    # create out recorder
    mRecorder = MediaRecorder()
    mRecorder.setAudioSource(AudioSource.MIC)
    mRecorder.setOutputFormat(OutputFormat.MPEG_4)
    mRecorder.setOutputFile('/sdcard/test_recording.mp4')
    mRecorder.setAudioEncoder(AudioEncoder.AMR_NB)
    mRecorder.prepare()

    # record 5 seconds
    mRecorder.start()
    sleep(5)
    mRecorder.stop()
    mRecorder.release()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top