I have an arduino portenta with the vision shield.
How can I save audio files?
I tried to fined a dedicated function on “audio” module with no secsess
Here’s a simple example, reset after the script is done and import raw PCM data with Audacity or something:
import image, audio, time
audio.init(channels=2, frequency=16000, gain_db=20, highpass=0.9883)
def audio_callback(buf):
try:
global fout
fout.write(buf)
except Exception as e:
print("exption:", e)
# Open PCM file
fout = open('test.pcm', 'w')
# Start audio streaming
audio.start_streaming(audio_callback)
# do something else
print("recording audio...")
start = time.ticks_ms()
while ((time.ticks_ms() - start) < 5000):
time.sleep_ms(100)
# Stop streaming
audio.stop_streaming()
fout.close()