Giter Site home page Giter Site logo

shazamapi's Introduction

Shazam Api

Install

pip3 install ShazamAPI

Also you need to install ffmpeg and ffprobe then add it to path

Usage

from ShazamAPI import Shazam

with open('filename.mp3', 'rb') as fp:
    mp3_file_content_to_recognize = fp.read()

recognize_generator = Shazam().recognize_song(mp3_file_content_to_recognize)
# or just:
#     recognize_generator = Shazam().recognize_song('filename.mp3')
for (offset, resp) in recognize_generator:
    print(offset, resp)

Credits to:

https://github.com/marin-m/SongRec

shazamapi's People

Contributors

leneko avatar notpushkin avatar numenorean 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

shazamapi's Issues

Cannot run the recognizer

Hi!
I'm trying to run the code, but i get the following error:

C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
File "C:/Users/###/shazam_executer.py", line 8, in
print(next(recognize_generator))
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ShazamAPI\api.py", line 31, in recognizeSong
self.audio = self.normalizateAudioData(self.songData)
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ShazamAPI\api.py", line 63, in normalizateAudioData
audio = AudioSegment.from_file(BytesIO(songData))
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pydub\audio_segment.py", line 685, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users###\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

I suppose it is because I didn't add ffprobe and ffmpeg to path, but what path are you talking about?
thanks!

Update

Could you push the update from github to pypi? So that your code example on github works? Because i believe that this update is not yet pushed #6

Response from server 400

I have cloned the project and setup my environment to run the project but getting the following error on execution:

(venv) iMacPercy:ShazamAPI percy$ /Users/percy/git/ShazamAPI/venv/bin/python /Users/percy/git/ShazamAPI/execute.py
Traceback (most recent call last):
File "/Users/percy/git/ShazamAPI/execute.py", line 14, in
print(next(recognize_generator)) # current offset & shazam response to recognize requests
File "/Users/percy/git/ShazamAPI/ShazamAPI/api.py", line 83, in recognizeSong
results = self.sendRecognizeRequest(signature)
File "/Users/percy/git/ShazamAPI/ShazamAPI/api.py", line 113, in sendRecognizeRequest
raise Exception(error_message)
Exception: Request failed with status: 400, Response content:

getting a error while using example.

this example:

`from ShazamAPI import Shazam

mp3_file_content_to_recognize = open('1.mp3', 'rb').read()

shazam = Shazam(mp3_file_content_to_recognize)
recognize_generator = shazam.recognizeSong()
while True:
print(next(recognize_generator)) # current offset & shazam response to recognize requests
`
#why the error occurs the error is FileNotFoundError. But I Have The 1.mp3 Audio in Working Directory.

Unable to run the Shazam Recognizer

Hi,

I tried running the following code:
from ShazamAPI import Shazam

mp3_file_content_to_recognize = open('2_com.mp3', 'rb').read()
shazam = Shazam(mp3_file_content_to_recognize)
recognize_generator = shazam.recognizeSong()
while True:
print(next(recognize_generator))

I am getting the following error:

SSLError: HTTPSConnectionPool(host='amp.shazam.com', port=443): Max retries exceeded with url: /discovery/v5/ru/RU/iphone/-/tag/655074ED-134F-4831-8C92-89B8111F1EE5/7ADBDBAD-37B8-4957-B69E-9B7E2B53158D?sync=true&webv3=true&sampling=true&connected=&shazamapiversion=v3&sharehub=true&hubv5minorversion=v5.1&hidelb=true&video=v3 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

I am unable to resolve this. Can you please help? @Numenorean

Refactoring proposal

First of all, thank you for your wonderful work!

I'm currently linting some of your code โ€“ removing extraneous whitespace, tweaking code style (camelCase -> snake_case, etc), moving some hardcoded values out as constants (where it makes sense) etc. I'm largely using https://wemake-python-stylegui.de/ as a guide, but adding a lot of exceptions where it makes sense. You can see the documentation on the rules it recommends, it is really well written.

I then plan to tweak the API to allow passing a pydub.AudioSegment directly and be more flexible overall. Would you be interested in accepting a PR with these changes?

Song recognize issue

Hi! I have tested your code and figured out that some songs cannot be recognized. I cut a 20 second piece of a track and tested both your code and shazam on my phone (phone mic) and the code failed but the phone successfully recognized it. Is this an algorithm related issue?

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.