To upload the file, the POST method was used on the same page and would upload the file to a temporary directory and would then move it to the correct directory which would be the folder where audio is played from.
To play the audio uploaded first I tried the in-built aplay from the ALSA system, however it did not play the audio and instead just played noise. So instead the mpg123 package was installed and tested. This was easily installed and used a small amount CPU between 1-5%. After modifying the permissions for the site to be able to run the mpg123 package on the audio folder, the audio could be played as many times as possible. To make sure it can only be played once, a setuid was used to kill the process at any point - as this is a prototype this is acceptable to show the behaviour of the system, however its likely this would need changing to ensure that this does not open a security issue.
After testing the audio from mobile devices, the mobile audio was in the format .m4a. The package mpg123 only plays mp3 formatted files. So initially converting any file to MP3 was considered, but it would be the most inefficient method. Instead, more console players were looked into, and eventually the player called SoX was found which supported a lot of different formats. Following the same process for setting up mpg123, SoX was easily installed and was successful with running mobile recordings. SoX also has a built-in function to repeat audio files however many times specified. This was implemented later as an additional function which seemed beneficial to the system - as owners call for their cats multiple times sometimes. This would add a layer of personalisation.
Once implemented, there was one issue that was incurred randomly, where the speaker would not be recognised when all of the usb devices were plugged in, usually this could be resolved by restarting the RPi. However, in an effort to eliminate the issue, I decided to overclock the device to the preset Medium setting for overclocking (along with a small amount of overvolting). This did improve the issue and did not appear too frequently, and hopefully provided an added level of stability with the amount of devices connected.
Once implemented, there was one issue that was incurred randomly, where the speaker would not be recognised when all of the usb devices were plugged in, usually this could be resolved by restarting the RPi. However, in an effort to eliminate the issue, I decided to overclock the device to the preset Medium setting for overclocking (along with a small amount of overvolting). This did improve the issue and did not appear too frequently, and hopefully provided an added level of stability with the amount of devices connected.
