Closed drew-linerud closed 3 years ago
Internally, play_file
uses the aplay
command. Could you try running this command and see if it is able to play your file? If not, are there any error messages?
/usr/bin/aplay path/to/Recording.wav
Try normalizing the sound to make it as loud as possible. Currently, the peaks are a small fraction of the available range.
Also, 16-bit, mono, 22050Hz sound format works best, otherwise the CPU on the EV3 has to do extra processing to convert the format on the fly.
Converting to 16-bit mono, 22050 Hz (352,800 bit rate) allowed it to work. Thanks for the quick answer! Would be awesome to add that format to the documentation.
ev3dev version:
4.14.117-ev3dev-2.3.5-ev3
ev3dev-lang-python version: ||/ Name Version Architecture Description +++-==============-============-============-================================= ii micropython-ev 2.1.0 all Python language bindings for ev3d ii python3-ev3dev 1.2.0 all Python language bindings for ev3d ii python3-ev3dev 2.1.0 all Python language bindings for ev3d
Hi, I'm not able to play audio from a wav file using Sound.play_file. Here's the code:
from ev3dev2.sound import Sound my_sound = Sound() my_sound.speak('Hello?') my_sound.play_file('Recording.wav', 100, Sound.PLAY_LOOP) my_sound.speak('Done')
If I don't include Sound.PLAY_LOOP in play_file, then the program completes successfully, just never playing the audio in Recording.wav. With PLAY_LOOP specified, the script speaks "Hello?" and then runs indefinitely without making another sound.
I also tried specifying the full path to Recording.wav which didn't seem to make any difference. I verified that the file is on the device in the same folder with the script.
Am I doing something wrong, or is this a bug? Attaching a zip file with my small .wav file.
audio.zip