I recently downloaded ACRCloud and began trying to use it to recognize music on the Raspberry Pi. So, the first thing I did was run the setup.py script with the following command:
sudo python setup.py install
Everything runs fine and all the necessary files are created. Next thing I did was enter my API information into the test.py file. It currently looks like this with the information entered:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
'''
>>> python test.py test.mp3
'''
import os, sys
from acrcloud.recognizer import ACRCloudRecognizer
from acrcloud.recognizer import ACRCloudRecognizeType
if __name__ == '__main__':
config = {
'host':'--------------',
'access_key':'--------------',
'access_secret':'--------------',
'recognize_type': ACRCloudRecognizeType.ACR_OPT_REC_AUDIO, # you can replace it with [ACR_OPT_REC_AUDIO,ACR_OPT_REC_HUMMING,ACR_OPT_REC_BOTH], The SDK decide which type fingerprint to create accordings to "recognize_type".
'debug':False,
'timeout':10 # seconds
}
'''This module can recognize ACRCloud by most of audio/video file.
Audio: mp3, wav, m4a, flac, aac, amr, ape, ogg ...
Video: mp4, mkv, wmv, flv, ts, avi ...'''
re = ACRCloudRecognizer(config)
#recognize by file path, and skip 0 seconds from from the beginning of sys.argv[1].
print re.recognize_by_file(sys.argv[1], 0, 10)
buf = open(sys.argv[1], 'rb').read()
#recognize by file_audio_buffer that read from file path, and skip 0 seconds from from the beginning of sys.argv[1].
print re.recognize_by_filebuffer(buf, 0, 10
Nothing other than the host, access key, or access secret have been touched, and I removed them here. Next, I try running the following command:
sudo python test.py test.mp3
This should return the song, as my directory contains both files. ls -la returns the following:
drwxrwxrwx 6 pi pi 4096 Mar 9 15:26 .
drwxr-xr-x 3 pi pi 4096 Feb 15 08:36 ..
drwxrwxrwx 2 pi pi 4096 Mar 9 01:08 acrcloud
drwxr-xr-x 4 root root 4096 Mar 9 00:46 build
drwxr-xr-x 2 root root 4096 Mar 9 00:46 dist
drwxr-xr-x 2 root root 4096 Mar 9 00:46 pyacrcloud.egg-info
-rw-r--r-- 1 pi pi 570 Feb 15 08:36 setup.py
-rw-r--r-- 1 pi pi 10724969 Mar 9 01:07 test.mp3
-rw-r--r-- 1 pi pi 1291 Mar 9 01:05 test.py
-rw-r--r-- 1 pi pi 12288 Mar 9 00:54 .test.py.swp
However, when I run the command above, I get the following error:
Traceback (most recent call last):
File "test.py", line 9, in <module>
from acrcloud.recognizer import ACRCloudRecognizer
File "/home/pi/Downloads/ACRCloud/raspberrypi/python2.7/acrcloud/recognizer.py", line 21, in <module>
import acrcloud_extr_tool
ImportError: /home/pi/Downloads/ACRCloud/raspberrypi/python2.7/acrcloud/acrcloud_extr_tool.so: cannot open shared object file: No such file or directory
I have checked to ensure that the shared object file is where it says it is. Doing ls -la in the python2.7/acrcloud directory gives me the following:
drwxrwxrwx 2 pi pi 4096 Mar 9 01:08 .
drwxrwxrwx 6 pi pi 4096 Mar 9 15:26 ..
-rwxr-xr-x 1 pi pi 11270324 Feb 15 08:36 acrcloud_extr_tool.so
-rw-r--r-- 1 pi pi 182 Feb 15 08:36 __init__.py
-rw-r--r-- 1 root root 157 Mar 9 01:08 __init__.pyc
-rwxr-xr-x 1 pi pi 10990 Feb 15 08:36 recognizer.py
-rw-r--r-- 1 root root 8693 Mar 9 01:08 recognizer.pyc
So it's pretty clear that I have everything there, and it's not a privilege issue. Not entirely sure what I should do.
Apologies for the lengthy post, just wanted to be completely thorough.
Thanks