Last active
December 12, 2015 01:49
-
-
Save bradymholt/4694195 to your computer and use it in GitHub Desktop.
Unattended podcast recording and processing. http://www.geekytidbits.com/raspberry-pi-unattended-audio-recordings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Unattended podcast record process | |
# Author: [email protected] | |
# Notes: Invoke with seconds parameter specifying how many seconds to record, ex. 'podcast-record.sh 10' | |
FILENAME=$(date +"%Y%m%d_%H%M") | |
#record with sudo since arecord seems to want root privledges | |
sudo arecord -f dat -d $1 ./record/${FILENAME}.wav | |
[ $? -eq 0 ] || exit $? | |
#change ownership to jdoe | |
sudo chown jdoe ./record/${FILENAME}.wav | |
[ $? -eq 0 ] || exit $? | |
#copy to process directory | |
cp ./record/${FILENAME}.wav ./process/${FILENAME}.wav | |
#stereo > mono | |
sox ./process/${FILENAME}.wav -c 1 ./process/${FILENAME}-mono.wav | |
#convert to mp3 (64Kpbs) | |
lame -b 64 ./process/${FILENAME}-mono.wav ./upload/${FILENAME}.mp3 | |
[ $? -eq 0 ] || exit $? | |
#remove process files | |
rm ./record/${FILENAME}.wav | |
rm ./process/${FILENAME}.wav | |
rm ./process/${FILENAME}-mono.wav | |
[email protected] | |
MODTIME=$(stat -c %y ./upload/${FILENAME}.mp3) | |
DATE=$(date --date="${MODTIME}" +%Y-%m-%d) | |
#upload to s3 | |
s3cmd put --reduced-redundancy --acl-public ./upload/${FILENAME}.mp3 s3://MY_S3_BUCKET/${FILENAME}.mp3 | |
[ $? -eq 0 ] || continue | |
#write db record | |
mysql -h www.mydomain.com -D MY_DB_NAME -u MY_DB_USERNAME -pMY_DB_PASSWORD --execute "INSERT INTO Lesson (Date, Title, Speaker, Audio_File_Name) VALUES ('${DATE}', 'TBD', 'TBD', '${FILENAME}.mp3')" | |
[ $? -eq 0 ] || continue | |
mv ./upload/${FILENAME}.mp3 ./complete/ | |
#send email | |
echo "Done!" | mail -s "Podcast ${DATE} - Upload Complete" $NOTIFY_EMAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment