Forums » General Discussion Search

Uploading and analyzing New Reply

Author Post
Posts: 5
Registered: Mar 31, 2010

Hi all,

I've been trying for some days now to use pyechonest for analyzing a number of songs (ca. 300) - this is a pretest of a study for my PhD thesis in marketing.

As I do not have any experience with Python (nor with Flash or Java, by the way), my attempts were not very successful until now. Although I managed to install the API and to execute the examples, I could not find any advice or examples about how to upload songs and analyze RPM, key, mode etc. of several files, i.e. how the "track" methods are used in proper Python syntax.

Probably the script I'd need would be a rather simple one - does anybody happen to have examples that I can use as a starting point (besides the ones on this website)? I'm pretty sure I'll be able to come up with something once I see how the objects are used properly...

Thanks and have a good time, Klemens

Posts: 6
Registered: Jun 20, 2009

Hello!

I'm also looking for the same. - Just need to upload 1 file - And, get analysis results.

Do you happen to have the code snippet?

Regards, ~Arijit

Posts: 666
Registered: Sep 08, 2008

Hi Kelmens, Arijit.

We are working on adding lots of examples on how to use the Echo Nest APIs. We'll have them published on the dev site really soon. In the meantime, here's an example of using pyechonest to upload a file, retrieve and dump its analysis:

from pyechonest import config
config.ECHO_NEST_API_KEY='YOUR API KEY'

from pyechonest import track

c_major = track.track_from_filename('c_major.mp3', filetype='mp3')

for attr in ['analysis_channels', 'analysis_sample_rate', 'analysis_url', 'artist', 'audio_md5', 'danceability', 'duration', 'end_of_fade_in', 'energy', 'id', 'key', 'key_confidence', 'loudness', 'md5', 'meta', 'mode', 'mode_confidence', 'num_samples', 'sample_md5', 'start_of_fade_out', 'status', 'tempo', 'tempo_confidence', 'time_signature', 'time_signature_confidence', 'title']:
print '%-30s %s' % (attr, getattr(c_major, attr))

print ''

for dicts_attr in ['bars', 'beats', 'sections', 'segments', 'tatums']:
    print '"%s" example dict:' % (dicts_attr)
    if getattr(c_major, dicts_attr):
        for key, val in getattr(c_major, dicts_attr)[0].iteritems():
            print '    %-26s %s' % (key, val)
    print ''

print 'segment pitches:'
print ('%8s    ' + '%-4s ' * 12) % ('start', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B')
for a_dict in c_major.segments:
    print ('%8.2f    ' + '%4.2f ' * 12) % ((a_dict['start'], ) + tuple(a_dict['pitches']))
Posts: 2
Registered: Sep 28, 2011

hi plamere, can you give me an example about how to upload mp3 files from PHP?? and how to get song_id from that json file and bring it into new variable. i'm very confused bout the cURL PHP in upload page..

Posts: 2
Registered: Sep 28, 2011

hi plamere, can you give me an example about how to upload mp3 files from PHP?? and how to get song_id from that json file and bring it into new variable. i'm very confused bout the cURL PHP in upload page..

Reply to this Thread

You must log in to post a reply.