kdave / audio-compare

Chromaprint + fpcalc + python + statistics = compare audio files and determine similarity
71 stars 17 forks source link

File not found #4

Open ryanbrooks816 opened 1 year ago

ryanbrooks816 commented 1 year ago
Calculating fingerprint by fpcalc for 754942426.wav
Traceback (most recent call last):
  File "E:\...\compare.py", line 20, in <module>
    correlate(SOURCE_FILE, TARGET_FILE)
  File "E:\...\correlation.py", line 107, in correlate
    fingerprint_source = calculate_fingerprints(source)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\...\correlation.py", line 30, in calculate_fingerprints
    fpcalc_out = str(subprocess.check_output(['fpcalc', '-raw', '-length', str(sample_time), filename])).strip().replace('\\n', '').replace("'", "")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 465, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 546, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\***\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
nam-usth commented 1 year ago

Hi there, you also need to download the file chromaprint-fpcalc-1.5.1-windows-x86_64.zip (1.5 MB) from https://acoustid.org/chromaprint

Then please unzip the binary file (.exe) into the same folder with the compare.py.

After that, you should see the fpcalc.exe is in the same place with compare.py and correlation.py. Hence in line 30 in correlation.py, the subprocess can be able to call the fpcalc for your audio file

nam-usth commented 1 year ago

And if you found the same error as me while comparing audio files like:

    ...
  File "H:\audio-compare\correlation.py", line 37, in calculate_fingerprints
    fingerprints = list(map(int, fpcalc_out[fingerprint_index:].split(',')))

ValueError: invalid literal for int() with base 10: '3497912292\\r'

You can add the .replace("\\r", "") to line 30 in correlation.py. Your line 30 should end up like this: fpcalc_out = str(subprocess.check_output(['fpcalc', '-raw', '-length', str(sample_time), filename])).strip().replace('\\n', '').replace("'", "").replace("\\r", "")