Code Monkey home page Code Monkey logo

adblockradio's Introduction

Adblock Radio (project archived)

Adblock Radio

A library to block ads on live radio streams and podcasts. Machine learning meets Shazam.

Engine of AdblockRadio.com. Demo standalone player available here.

Build status: CircleCI

Help the project grow: Donate using Liberapay

Overview

A technical discussion is available here.

Radio streams are downloaded in predictor.js with the module adblockradio/stream-tireless-baler. Podcasts are downloaded in predictor-file.js.

In both cases, audio is then decoded to single-channel, 22050 Hz PCM with ffmpeg.

Chunks of about one second of PCM audio are piped into two sub-modules:

  • a time-frequency analyser (predictor-ml/ml.js), that analyses spectral content with a neural network.
  • a fingerprint matcher (predictor-db/hotlist.js), that searches for exact occurrences of known ads, musics or jingles.

In post-processing.js, results are gathered for each audio segment and cleaned.

A Readable interface, Analyser, is exposed to the end user. It streams objects containing the audio itself and all analysis results.

On a regular laptop CPU and with the Python time-frequency analyser, computations run at 5-10X for files and at 10-20% usage for live stream.

Getting started

Installation

Mandatory prerequisites:

You need Node.js (>= v10.12.x, but < 11) and NPM. Download it here. Pro-tip: to manage several node versions on your platform, use NVM.

On Debian Stretch:

apt-get install -y git ssh tar gzip ca-certificates build-essential sqlite3 ffmpeg

Note: works on Jessie, but installing ffmpeg is a bit painful. See here and there.

Optional prerequisites:

For best performance (~2x speedup) you should choose to do part of the computations with Python. Additional prerequisites are the following: Python (tested with v2.7.9), Keras (tested with v2.0.8) and Tensorflow (tested with CPU v1.4.0 and GPU v1.3.0).

On Debian:

apt-get install python-dev portaudio19-dev
pip install python_speech_features h5py numpy scipy keras tensorflow zerorpc sounddevice psutil

Note: if you do not have pip follow these instructions to install it.

Then install this module:
git clone https://github.com/adblockradio/adblockradio.git
cd adblockradio
npm install

Testing

Validate your installation with the test suite:

npm test

Command-line demo

At startup and periodically during runtime, filter configuration files are automatically updated from adblockradio.com/models/:

  • a compatible machine-learning model (model.keras or model.json + group1-shard1of1), for the time-frequency analyser.
  • a fingerprint database (hotlist.sqlite), for the fingerprint matcher.

Live stream analysis

Run the demo on French RTL live radio stream:

node demo.js

Here is a sample output of the demo script, showing an ad detected:

{
	"gain": 74.63,
	"ml": {
		"class": "0-ads",
		"softmaxraw": [
			0.996,
			0.004,
			0
		],
		"softmax": [
			0.941,
			0.02,
			0.039
		],
		"slotsFuture": 4,
		"slotsPast": 5
	},
	"hotlist": {
		"class": "9-unsure",
		"file": null,
		"matches": 1,
		"total": 7
	},
	"class": "0-ads",
	"metadata": {
		"artist": "Laurent Ruquier",
		"title": "L'été des Grosses Têtes",
		"cover": "https://cdn-media.rtl.fr/cache/wQofzw9SfgHNHF1rqJA3lQ/60v73-2/online/image/2014/0807/7773631957_laurent-ruquier.jpg"
	},
	"streamInfo": {
		"url": "http://streaming.radio.rtl.fr/rtl-1-44-128",
		"favicon": "https://cdn-static.rtl.fr/versions/www/6.0.637/img/apple-touch-icon.png",
		"homepage": "http://www.rtl.fr/",
		"audioExt": "mp3"
	},
	"predictorStartTime": 1531150137583,
	"playTime": 1531150155250,
	"tBuffer": 15.98,
	"audio": ...
}

Podcast analysis

It is also possible to analyse radio recordings. Run the demo on a recording of French RTL radio, including ads, talk and music:

node demo-file.js

Gradual outputs are similar to those of live stream analysis. An additional post-processing specific to recordings hides the uncertainties in predictions and shows big chunks for each class, with time stamps in milliseconds, making it ready for slicing.

[
	{
		"class": "1-speech",
		"tStart": 0,
		"tEnd": 58500
	},
	{
		"class": "0-ads",
		"tStart": 58500,
		"tEnd": 125500
	},
	{
		"class": "1-speech",
		"tStart": 125500,
		"tEnd": 218000
	},
	{
		"class": "2-music",
		"tStart": 218000,
		"tEnd": 250500
	},
	{
		"class": "1-speech",
		"tStart": 250500,
		"tEnd": 472949
	}
]

Note that when analyzing audio files, you still need to provide the name of a radio stream, because the algorithm has to load acoustic parameters and DB of known samples. Analysis of podcasts not tied to a radio is not yet supported, but may possibly be in the future.

Documentation

Usage

Below is a simple usage example. More thorough usage examples are available in the tests:

  • file/podcast analysis: test/file.js
  • live stream analysis: test/online.js
  • record a live stream, analyse it later: test/offline.js
const { Analyser } = require("adblockradio");

const abr = new Analyser({
	country: "France",
	name: "RTL",
	config: {
		...
	}
});

abr.on("data", function(obj) {
	...
});
Property Description Default
country Country of the radio stream according to radio-browser.info None
name Name of the radio stream according to radio-browser.info None
file File to analyse (optional, analyse the live stream otherwise) None

Methods

Acoustic model and hotlist files are refreshed automatically on startup. If you plan to continuously run the algo for a long time, you can trigger manual updates. Note those methods are only available in live stream analysis mode.

Method Parameters Description
refreshPredictorMl None Manually refresh the ML model (live stream only)
refreshPredictorHotlist None Manually refresh the hotlist DB (live stream only)
refreshMetadata None Manually refresh the metadata scraper (live stream only)
stopDl None Stop Adblock Radio (live stream only)

Optional configuration

Properties marked with a * are meant to be used only with live radio stream analysis, not file analysis where they are ignored.

Scheduling

Property Description Default
predInterval Send stream status to listener every N seconds 1
saveDuration* If enabled, save audio file and metadata every N predInterval times 10
modelUpdatesInterval If enabled, update model files every N minutes 60

Switches

Property Description Periodicity Default
enablePredictorMl Perform machine learning inference predInterval true
JSPredictorMl Use tfjs instead of Python for ML inference (slower) false
enablePredictorHotlist Compute audio fingerprints and search them in a DB predInterval true
saveAudio* Save stream audio data in segments on hard drive saveDuration true
saveMetadata Save a JSON with predictions saveDuration true
fetchMetadata* Gather metadata from radio websites saveDuration true
modelUpdates Keep ML and hotlist files up to date modelUpdatesInterval true

Paths

Property Description Default
modelPath Directory where ML models and hotlist DBs are stored process.cwd() + '/model'
modelFile Path of ML file relative to modelPath country + '_' + name + '/model.keras'
hotlistFile Path of the hotlist DB relative to modelPath country + '_' + name + '/hotlist.sqlite'
saveAudioPath* Root folder where audio and metadata are saved process.cwd() + '/records'

Output

Readable streams constructed with Analyser emit objects with the following properties. Some properties are only available when doing live radio analysis. They are marked with a *. Other specific to file analysis are marked with **.

  • audio*: Buffer containing a chunk of original (compressed) audio data.

  • ml: null if not available, otherwise an object containing the results of the time-frequency analyser

    • softmaxraw: an array of three numbers representing the softmax between ads, speech and music.
    • softmax: same as softmaxraw, but smoothed in time with slotsFuture data points in the future and slotsPast data points in the past. Smoothing weights are defined by consts.MOV_AVG_WEIGHTS in post-processing.js.
    • class: either 0-ads, 1-speech, 2-music or 9-unsure. The classification according to softmax.
  • hotlist: null if not available, otherwise an object containing the results of the fingerprint matcher.

    • file: if class is not "9-unsure", the reference of the file recognized.
    • total: number of fingerprints computed for the given audio segment.
    • matches: number of matching fingerprints between the audio segment and the fingerprint database.
    • class: either 0-ads, 1-speech, 2-music, 3-jingles or 9-unsure if not enough matches have been found.
  • class: final prediction of the algorithm. Either 0-ads, 1-speech, 2-music, 3-jingles or 9-unsure.

  • metadata*: live metadata, fetched and parsed by the module adblockradio/webradio-metadata.

  • streamInfo*: static metadata about the stream. Contains stream url, favicon, bitrate in bytes / s, audio files extension audioExt (mp3 or aac) and homepage URL.

  • gain: a dB value representing the average volume of the stream. Useful if you wish to normalize the playback volume. Calculated by mlpredict.py.

  • tBuffer*: seconds of audio buffer. Calculated by adblockradio/stream-tireless-baler.

  • predictorStartTime*: timestamp of the algorithm startup. Useful to get the uptime.

  • playTime*: approximate timestamp of when the given audio is to be played. TODO check this.

  • tStart**: lower boundary of the time interval linked with the prediction (in milliseconds)

  • tEnd**: upper boundary of the time interval linked with the prediction (in milliseconds)

Supported radios

The list of supported radios is available here.

Note to developers

Integrations of this module are welcome. Suggestions are available here.

A standalone demo player for web browsers is available here.

License

See LICENSE file.

Your contribution to this project is welcome, but might be subject to a contributor's license agreement.

adblockradio's People

Contributors

dest4 avatar samyak2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adblockradio's Issues

Video Support?

This should work for all media, including Live TV.
Youtube TV is unwatchable with ads, you can skip through DVR'ed shows, but doing it manually is tiresome.

ml null

Hi Alexandre!
Following the instructions for installation and run the demo, I have this result:

status={ "liveResult": { "ml": null, "hotlist": null, "class": "9-unsure", "softmax": [ 0, 0, 0, 0 ], "audio": "[redacted]", "predictorStartTime": 1562903441509, "metadata": null, "streamInfo": { "url": "http://cadena100-streamers-mp3.flumotion.com/cope/cadena100.mp3", "bitrate": 16000, "favicon": "https://d1v6pqrrmmnutj.cloudfront.net/post_square_images/attachments/000/000/821/original/cadena100.png?2015", "homepage": "http://www.cadena100.es", "audioExt": "mp3" }, "playTime": 1562903445851, "tBuffer": 0 }

I have downloaded the model of the Radio and put those files in model folder, but no prediction is made, should I do something else?

Also, I have this deprecation error, this is normal?

[2019-07-12T03:50:44.473Z] error pred-ml: Spain_Cadena 100 mlpredict child stderr data: WARNING: Logging before flag parsing goes to stderr. W0711 22:50:44.473676 140107082598208 deprecation_wrapper.py:119] From /media/daniel/Datos/tf/adblockradio/predictor-ml/mlpredict.py:57: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

Thanks

installation problems

Trying to install adblockradio fails miserably. The error messages pasted below... any hints?

> [email protected] postinstall /Users/nicolas.busca/Documents/adblockradio
> install-app-deps

  • please use as subcommand: electron-builder install-app-deps
  • electron-builder version=20.38.2
  • rebuilding native production dependencies platform=darwin arch=x64
Error: /usr/local/bin/node exited with code 1
Output:

> [email protected] install /Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3240000/sqlite3.c
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3240000/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3240000/sqlite3.o
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3240000/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)

Error output:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.4/electron-v1.4-darwin-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v1.4 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (electron-v1.4 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Connection closed while downloading tarball file
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/database.cc:4:
../src/database.h:6:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/database.cc:4:
../src/database.h:6:10: fatal error: 'string' file not found
#include <string>
         ^~~~~~~~
1 warning and 1 error generated.
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/nicolas.busca/Documents/adblockradio/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/nicolas.busca/Documents/adblockradio/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nicolas.busca/.npm/_logs/2019-01-25T15_11_35_831Z-debug.log
1 warning and 1 error generated.
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /Users/nicolas.busca/Documents/adblockradio/node_modules/sqlite3
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

    at ChildProcess.childProcess.once.code (/Users/nicolas.busca/Documents/adblockradio/node_modules/builder-util/src/util.ts:244:14)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:610:12)
From previous event:
    at _rebuild (/Users/nicolas.busca/Documents/adblockradio/node_modules/app-builder-lib/src/util/yarn.ts:179:5)
    at rebuild (/Users/nicolas.busca/Documents/adblockradio/node_modules/app-builder-lib/out/util/yarn.js:163:19)
    at /Users/nicolas.busca/Documents/adblockradio/node_modules/app-builder-lib/src/util/yarn.ts:20:11
From previous event:
    at _installOrRebuild (/Users/nicolas.busca/Documents/adblockradio/node_modules/app-builder-lib/out/util/yarn.js:71:28)
    at installOrRebuild (/Users/nicolas.busca/Documents/adblockradio/node_modules/app-builder-lib/out/util/yarn.js:55:28)
    at /Users/nicolas.busca/Documents/adblockradio/node_modules/electron-builder/src/cli/install-app-deps.ts:56:9
    at Generator.next (<anonymous>)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
From previous event:
    at _installAppDeps (/Users/nicolas.busca/Documents/adblockradio/node_modules/electron-builder/out/cli/install-app-deps.js:176:26)
    at installAppDeps (/Users/nicolas.busca/Documents/adblockradio/node_modules/electron-builder/out/cli/install-app-deps.js:144:26)
    at main (/Users/nicolas.busca/Documents/adblockradio/node_modules/electron-builder/src/cli/install-app-deps.ts:65:10)
    at Object.<anonymous> (/Users/nicolas.busca/Documents/adblockradio/node_modules/electron-builder/src/cli/install-app-deps.ts:70:3)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nicolas.busca/.npm/_logs/2019-01-25T15_11_35_981Z-debug.log

Zerorpc was compiled against a different Node.js version

When running node demo.js, you may encounter the following error:

internal/modules/cjs/loader.js:718
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '.../adblockradio/node_modules/zerorpc/node_modules/zeromq/build/Release/zmq.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 50. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (.../adblockradio/node_modules/zerorpc/node_modules/zeromq/lib/index.js:6:11)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

Solution is to run:
npm rebuild zeromq

Make algorithm JS only

Communication between Node and Python is a pain for portability. Furthermore, the native zeromq IPC lib has to be built at installation. Damn, let's make Adblock Radio algorithm JS only, so that it could be shipped as a big Node.js file (and, with a proper solution for ffmpeg, as a browser JS in the future).

Test failure

Hi, I'm getting a test failure.
Here's the list of commands I used to install. This is on a fresh Debian Stretch vm (9.11):
apt install curl
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt update
apt install nodejs
apt-get install -y git ssh tar gzip ca-certificates build-essential sqlite3 ffmpeg
apt-get install python-dev portaudio19-dev
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install python_speech_features h5py numpy scipy keras tensorflow zerorpc sounddevice psutil
git clone https://github.com/adblockradio/adblockradio.git
cd adblockradio/
npm install
npm test

Below is the full output of "npm test", the most telling of the errors seems to be:
File "/root/adblockradio/predictor-ml/mlpredict.py", line 57, in get_session
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_fraction)
AttributeError: 'module' object has no attribute 'GPUOptions'

It sounds like it may be a dependency version issue? There is no GPU passed through to the vm, which may also be a factor.

[email protected] test /root/adblockradio
mocha --delay test/file.js && mocha --delay test/file.js --mljs && mocha --delay test/online.js && mocha --delay test/online.js --mljs && mocha --delay test/offline.js && mocha --delay test/offline.js --mljs

[2019-10-06T12:53:22.667Z] warn post-processing: updating ML model is not possible when analysing files. skip.
[2019-10-06T12:53:22.671Z] warn post-processing: updating hotlist DB is not possible when analysing files. skip.
[2019-10-06T12:53:22.672Z] warn post-processing: updating hotlist DB is not possible when analysing files. skip.
[2019-10-06T12:53:22.673Z] warn post-processing: not possible (yet?) to stop the processing of files. please kill the process instead.
[2019-10-06T12:53:22.674Z] info test-file: refresh attempted. result=false
[2019-10-06T12:53:23.177Z] info checkModelUpdates: /root/adblockradio/model/France_RTL/model.keras.tar.gz is up to date
[2019-10-06T12:53:23.863Z] info checkModelUpdates: /root/adblockradio/model/France_RTL/hotlist.sqlite.tar.gz is up to date
[2019-10-06T12:53:23.864Z] info predictor: run predictor on file /root/adblockradio/test/file.mp3 with config={"predInterval":1,"saveDuration":10,"enablePredictorMl":true,"enablePredictorHotlist":true,"saveMetadata":true,"verbose":false,"modelPath":"/root/adblockradio/model","hotlistFile":"France_RTL/hotlist.sqlite","modelUpdates":true,"modelUpdateInterval":60,"JSPredictorMl":false,"modelFile":"France_RTL/model.keras"}
[2019-10-06T12:53:23.874Z] debug predictor: readAmount=44100 bytes
[2019-10-06T12:53:23.878Z] info pred-hotlist: open hotlist db /root/adblockradio/model/France_RTL/hotlist.sqlite (memory=true)
[2019-10-06T12:53:23.881Z] info pred-ml: France_RTL Python predictor. __dirname=/root/adblockradio/predictor-ml env: PKG=false Electron=false
[2019-10-06T12:53:24.063Z] info pred-hotlist: /root/adblockradio/model/France_RTL/hotlist.sqlite db found
[2019-10-06T12:53:24.311Z] info pred-hotlist: France_RTL: Hotlist ready
[2019-10-06T12:53:25.119Z] info predictor: decoding finished
[2019-10-06T12:53:27.056Z] error pred-ml: France_RTL mlpredict child stderr data: Traceback (most recent call last):

[2019-10-06T12:53:27.057Z] error pred-ml: France_RTL mlpredict child stderr data: File "/root/adblockradio/predictor-ml/mlpredict.py", line 64, in

[2019-10-06T12:53:27.059Z] error pred-ml: France_RTL mlpredict child stderr data: tensorflow_backend.set_session(get_session())
File "/root/adblockradio/predictor-ml/mlpredict.py", line 57, in get_session
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_fraction)
AttributeError: 'module' object has no attribute 'GPUOptions'

[2019-10-06T12:54:22.027Z] error test-file: analysis timed out or was too slow. kill it.

File analysis (Python child process)
1) should have emitted data
2) should have reached the end of the file
✓ should reject attempts to reload ML model, hotlist DB or metadata scraper during analysis.
✓ should not have thrown errors
3) should have exited properly
4) should write results in JSON format

2 passing (46ms)
4 failing

  1. File analysis (Python child process)
    should have emitted data:

    AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(gotData)

  + expected - actual

  -false
  +true

  at Context.<anonymous> (test/file.js:93:4)
  1. File analysis (Python child process)
    should have reached the end of the file:

    AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(finished)

  + expected - actual

  -false
  +true

  at Context.<anonymous> (test/file.js:98:4)
  1. File analysis (Python child process)
    should have exited properly:
    AssertionError [ERR_ASSERTION]: null == 0
    at Context. (test/file.js:112:11)

  2. File analysis (Python child process)
    should write results in JSON format:

    AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

assert(fileOutputIsSane)

  + expected - actual

  -false
  +true

  at Context.<anonymous> (test/file.js:117:4)

npm ERR! Test failed. See above for more details.

How to use on a local file?

Hello,

I use streamripper to rip a daily mix a radio station I follow has. It's an hour long recording each day I have saved and I was wondering if it's possible to use your tool in order to strip the ads out of these local files? I see examples regarding live broadcasts, but wondered if there is a way to use it versus already recorded radio broadcasts?

pynode support

I have written a native node module for node to python foreign function interface interoperability. https://github.com/fridgerator/pynode. It allows python function calls from node via c++ bindings.

Here is a blog post about it being used with some ML python libraries.

I'm wondering if there is any interest in using PyNode for adblockradio. Unless being used for something else, it might allow this service to run without the requirement of zeromq.

Question: Support for Podcast Not Tied to a Radio?

In the README it mentions the possibility of future support for podcasts not tied to a radio. I listen to a ton of podcasts and would love to be able to create a podcast player that uses adblockradio to skip over ad reads.

From the description below, it looks like training data/sound configs specific to the radio station is needed before an analysis can be done. I'd like to see if I can get this working on a single popular podcast not tied to a radio station. If you have time would you be able to point me in the right direction to get this feature implemented. I'd really appreciate the guidance.

Relevant README section

Note that when analyzing audio files, you still need to provide the name of a radio stream, because the algorithm has to load acoustic parameters and DB of known samples. Analysis of podcasts not tied to a radio is not yet supported, but may possibly be in the future.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.