Convert audio into spectrograms.
You may want to run everything in a virtualenv. In the project root directory:
$ virtualenv -p python3 .
Then activate:
$ source bin/activate
And to install requires packages:
$ pip3 install -r requirements.txt
This code requires the 'ffmpeg' command-line utility to be installed in order to work.
On Linux: $ apt update && apt install -y ffmpeg
On Mac OS with Homebrew: $ brew install ffmpeg
$ python3 youtube_download.py --url https://www.youtube.com/watch?v=yoZPVMEsbeQ
$ python3 video2spectrogram.py --vid_name Ag60ZF-IdKk.mp4 --out_name dummy.wav --t_start 1 --cut_length 10
In the directory containing the Dockerfile, do:
$ docker build --tag yt2spec .
Run a container:
$ docker run -it yt2spec bash
Install docker and docker-compose following the official documentation:
-
Docker:
https://docs.docker.com/install/linux/docker-ce/ubuntu/
This installation process takes maybe 10 minutes, but you just copy/paste the instructions on that page into terminal/terminator.
-
Docker Compose:
Again, just follow the instructions.
To run docker without sudo, you need to create the docker group:
-
Create the docker group.
$ sudo groupadd docker
-
Add your user to the docker group.
$ sudo usermod -aG docker $USER
-
Log out and log back in so that your group membership is re-evaluated.
-
Verify that you can run docker commands without sudo.
$ docker run hello-world
Now, in the project root containing 'docker-compose.yml':
$ docker-compose down ; docker-compose up --build
If you have made edits to the Dockerfile, then you need to rebuild the image:
$ docker-compose up --build
Try out the 'yt2melspec' route/endpoint:
$ curl --header "Content-Type: application/json" \
--request POST \
--data '{"url":"https://www.youtube.com/watch?v=ilNEqmfUyzI"}' \
localhost:6060/yt2melspec
The response will look like:
{"spec_url":"/static/1608ee35-f343-460b-8e84-ffc5a31e015c.png","url":"https://www.youtube.com/watch?v=ilNEqmfUyzI"}