I want to record sound for 1 second using a Python written app for SL4A and then find the max amplitude of the sound.
Is there any part of the SL4A API I can use or part of the Python APIs that can be used? Or is there any python module I can install for this matter?
I've searched the Python API from SL4A but haven't found anything related to amplitude. Maybe I just missed it.
UPDATE:
I've managed to import the wave.py
module into my code and try to open the recorded file. But when I access
wave.open("/sdcard/sl4aTemp/sound_sample.wav")
it throws this error,
File does not start with RIFF id
For those of you who are curious how my code looks here it is:
import android, audioop, time, wave
droid = android.Android()
print "Recording starts in: "
for i in range(0,5):
time.sleep(1)
print str(5-i)
time.sleep(1)
print "Speak!"
droid.recorderStartMicrophone('/sdcard/sl4aTemp/sound_sample.wav')
time.sleep(3)
droid.recorderStop()
print "Processing file in:"
for i in range(0,3):
print str(3-i)
time.sleep(1)
filename = "/sdcard/sl4aTemp/sound_sample.wav"
if wave.open(filename,"r") == True:
print "Processing " + filename
else:
print "File not processed"
FILE=wave.open(filename,"r")
rez=FILE.readframes(30)
print str(rez)