Created
March 7, 2020 22:11
-
-
Save peterkappus/3cb58b694eb06b7b16972718c74f26b6 to your computer and use it in GitHub Desktop.
Revisions
-
peterkappus created this gist
Mar 7, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ # Peter's Musical Notebook Record audio, compress to Flac & MP3 files, create an index.html with a link to each MP3 and synch the new index and the MP3s to an S3 bucket. ## Pre-requisites - Ruby - Sox - docker ## Setup 1. Create an S3 bucket. 2. Create a CNAME to point to it. 3. Create a "secrets.env" file and add - your AWS key - AWS Secret - S3 Bucket name where you want to upload the files 4. Copy the below into a script and run it. Read the comments to understand how it works. 5. Record some audio. When the audio stops, the script will compress it, generate a new index, and upload the MP3 and the new index to the S3 bucket. ``` #load secrets into env source secrets.env #record # https://gist.github.com/peterkappus/c1b8dfc621077c42019d21cf6f9ab624 file=$(date +%Y-%m-%dT%H%M%S%Z) && rec $file.flac silence 1 0:01 0.00599% 1 0:03 0.00599% norm compand 0.3,1 -5,-5 && sox $file.flac $file.mp3 #move mp3 to public folder mv $file.mp3 public/$file.mp3 #build index ruby mkindex.rb #sync 'public' folder to bucket docker run -v "$(pwd)"/public:/data --env AWS_ACCESS_KEY_ID=$AWS_ID --env AWS_SECRET_ACCESS_KEY=$AWS_SECRET garland/aws-cli-docker aws s3 sync . s3://$AWS_S3_BUCKET_NAME --delete --size-only --acl=public-read --exclude=".git*" ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ links = Dir.glob("public/*.mp3").map {|f| basename = File.basename(f); %(<a href="#{basename}">#{basename}</a>\n)}.join("<br>") IO.write "public/index.html", %(<html>#{links}</html>)