Listen to television audio, detect commercials, request decrease volume.
conda activate remy_python
pip install -e git+https://github.com/bcollazo/[email protected]#egg=PyDejavu
This installed directory src/pydejavu. I didn't delete file added by pip: src/pip-delete-this-directory.txt See also Appendix- Install dejavu dependencies.
If using Anaconda.
conda activate <my_environment>
conda activate remy_python
ffmpeg -i a.wav -f mp3 a.mp3
Selecting live audio input from an audio interface instead of from microphone gives a cleaner signal without room noise. If using macOS and an audio interface, go to System Preferences / Sound / Input. Select the interface e.g. Scarlett 2i4 USB. Note I haven't tried running Dejavu on Raspberry Pi Raspbian yet, and haven't selected an audio input source.
Optional step. Running test_dejavu.sh populates results directory including test.db Ok to delete contents of results directory.
$ chmod u+x ./src/pydejavu/test_dejavu.sh
$ ./src/pydejavu/test_dejavu.sh
check sqlite schema
https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python?rq=1
mysql://<user_name>:<password>@<host_name>/<db_name>
mysql+mysqlconnector://beepscore:password@localhost/dejavu
may contain a json dictionary e.g.
{"DATABASE_URL": "results/test.db"}
Ways to run: Can run recognize_audio.py If no database exists it will make a new one, I think in-memory sqlite.
conda activate <environment>
python3 recognize_audio.py
2019-04-21 18:42:17 DEBUG recognize_audio_from_a_file line:49
filename_containing_audio_to_match: data/commercial_mp3/chantix.mp3,
match_dict_json: {"song_id": 14, "song_name": "chantix", "confidence": 43335,
"offset": 0, "offset_seconds": 0.0, "file_sha1": "a4fcabb2afb6518a65321c5807c5fc7c798a0aa2",
"match_time": 11.153626918792725}
2019-04-21 18:42:48 DEBUG recognize_audio_from_microphone line:80
From mic with 5 seconds we recognized: {"song_id": 19,
"song_name": "tecovas-western-boots", "confidence": 179, "offset": 62,
"offset_seconds": 2.87927, "file_sha1": "ca324b141675b59c05bdcbbdf05c038d68940376"}
I used conda to install mysql-connector-python https://stackoverflow.com/questions/34168651/what-are-the-differences-between-mysql-connector-python-mysql-connector-python
Then ran recognize_audio.py
Got error "Can't connect to MySQL server on 'localhost' (61)" To use mysql, may need to start mysql server before running recognize_audio.py https://stackoverflow.com/questions/119008/cant-connect-to-mysql-server-on-localhost-10061
Note: unittest discover requires tests directory contain init.py cd to project root directory
conda activate remy_python
python -m unittest discover
I installed many of these as conda packages in environment remy_python. I don't know if installing dejavu from pip would handle this automatically. https://github.com/worldveil/dejavu/blob/master/INSTALLATION.md
for converting audio files to .wav format on macOS
brew install ffmpeg
used for spectrograms and plotting
for interfacing with MySQL databases
for taking the FFT of audio signals
a Python ffmpeg wrapper
used in peak finding algorithms
for grabbing audio from microphone
https://sqlalchemy-utils.readthedocs.io/en/latest/installation.html
sqlalchemy-utils
import sqlalchemy_utils
http://beepscore.com/website/2019/04/21/automatically-detecting-television-commercials.html
Audio fingerprinting and recognition in Python. It has recognizers for recorded files and for live microphone input. Originally by worldveil/dejavu, forked by DataWookie/dejavu and bcollazo/dejavu. In 2019-03 bcollazo/dejavu appeared to be the most active fork.
I forked bcollazo/dejavu as beepscore/dejavu and added branch "beepscore". https://github.com/beepscore/dejavu/tree/dejavu
Scarlett audio interface and PyAudio https://stackoverflow.com/questions/25620285/recording-multiple-microphones-in-python
Raspberry Pi 3 Model B and Focusrite Scarlett 2i2 USB Sound Card https://stackoverflow.com/questions/38042875/python2-7-on-raspberry-pi-3-pyaudio-input-overflowed
A Raspberry Pi infrared remote control. The Python app has three parts: Functions to send commands to the infrared transmitter. A Flask web service to accept television command requests (e.g. volume decrease, volume increase). A scheduler that automatically sends remote control commands at programmed times (e.g. mute during TV commercials). https://github.com/beepscore/remy_python
http://beepscore.com/website/2019/02/05/network-enabled-raspberry-pi-tv-remote-control.html
Remote control television by sending commands from iOS device to a server. https://github.com/beepscore/Remy
I used pip to install src/pydejavu and it isn't committed to this git repo. Manually edited src/pydejavu/dejavu/init.py
# import logging
import logging_util
...
# logger = logging.getLogger(__name__)
logger = logging_util.get_logger(__name__)