Class: Wavesync::PercivalBpmDetector
- Inherits:
-
Object
- Object
- Wavesync::PercivalBpmDetector
- Defined in:
- lib/wavesync/percival_bpm_detector.rb
Constant Summary collapse
- PYTHON_SCRIPT =
<<~PYTHON import essentia.standard as es, sys audio = es.MonoLoader(filename=sys.argv[1], sampleRate=44100)() bpm = es.PercivalBpmEstimator()(audio) print(round(float(bpm))) PYTHON
Class Method Summary collapse
-
.available? ⇒ Boolean
: () -> bool?.
-
.detect(file_path) ⇒ Object
: (String file_path) -> Integer?.
Class Method Details
.available? ⇒ Boolean
: () -> bool?
16 17 18 |
# File 'lib/wavesync/percival_bpm_detector.rb', line 16 def self.available? PythonVenv.essentia_available? end |
.detect(file_path) ⇒ Object
: (String file_path) -> Integer?
21 22 23 24 25 26 27 |
# File 'lib/wavesync/percival_bpm_detector.rb', line 21 def self.detect(file_path) output = PythonVenv.run_script(PYTHON_SCRIPT, file_path) bpm = output.strip.to_f bpm.positive? ? bpm.round : nil rescue StandardError nil end |