Track – track methods

class pyechonest.track.Track(identifier, md5, properties)

Represents an audio file and its analysis from The Echo Nest. All methods in this module return Track objects.

Depending on the information available, tracks may have some or all of the following attributes:

analysis_channels int: the number of audio channels used during analysis

analysis_sample_rate int: the sample rate used during analysis

analysis_url URL to retrieve the complete audio analysis (time expiring)

analyzer_version str: e.g. ‘3.01a’

artist str or None: artist name

artist_id Echo Nest ID of artist, if known

bars list of dicts: timing of each measure

beats list of dicts: timing of each beat

codestring ENMFP code string

code_version version of ENMFP code generator

danceability float: relative danceability (0.0 to 1.0)

decoder audio decoder used by the analysis (e.g. ffmpeg)

duration float: length of track in seconds

echoprintstring fingerprint string using Echoprint (http://echoprint.me)

echoprint_version version of Echoprint code generator

energy float: relative energy (0.0 to 1.0)

end_of_fade_in float: time in seconds track where fade-in ends

id str: Echo Nest Track ID, e.g. ‘TRTOBXJ1296BCDA33B’

key int: between 0 (key of C) and 11 (key of B flat) inclusive

key_confidence float: confidence that key detection was accurate

liveness float: confidence the track is “live” (0.0 to 1.0)

loudness float: overall loudness in decibels (dB)

md5 str: 32-character checksum of the original audio file, if available

meta dict: other track metainfo (bitrate, album, genre, etc.)

mode int: 0 (major) or 1 (minor)

mode_confidence float: confidence that mode detection was accurate

num_samples int: total samples in the decoded track

offset_seconds unused, always 0

sample_md5 str: 32-character checksum of the decoded audio file

sections list of dicts: larger sections of song (chorus, bridge, solo, etc.)

segments list of dicts: timing, pitch, loudness and timbre for each segment

song_id The Echo Nest song ID for the track, if known

speechiness float: likelihood the track contains speech (0.0 to 1.0)

start_of_fade_out float: time in seconds where fade out begins

status str: analysis status, e.g. ‘complete’

synchstring string providing synchronization points throughout the track

synch_version version of the synch string algorithm

tatums list of dicts: the smallest metrical unit (subdivision of a beat)

tempo float: overall BPM (beats per minute)

tempo_confidence float: confidence that tempo detection was accurate

time_signature beats per measure (e.g. 3, 4, 5, 7)

time_signature_confidence float: confidence that time_signature detection was accurate

title str or None: song title

window_seconds unused, always 0

Each bar, beat, section, segment and tatum has a start time, a duration, and a confidence, in addition to whatever other data is given.

Examples:

>>> t = track.track_from_id('TRJSEBQ1390EC0B548')
>>> t
<track - Dark Therapy>
>>> t = track.track_from_md5('96fa0180d225f14e9f8cbfffbf5eb81d')
>>> t
<track - Spoonful - Live At Winterland>
>>> 
__repr__()
__str__()
static track.track_from_file(file_object, filetype, timeout=60, force_upload=False)

Create a track object from a file-like object.

Args:
file_object: a file-like Python object filetype: the file type. Supported types include mp3, ogg, wav, m4a, mp4, au force_upload: skip the MD5 shortcut path, force an upload+analysis
Example:
>>> f = open("Miaow-01-Tempered-song.mp3")
>>> t = track.track_from_file(f, 'mp3')
>>> t
< Track >
>>>
static track.track_from_filename(filename, filetype=None, timeout=60, force_upload=False)

Create a track object from a filename.

Args:
filename: A string containing the path to the input file. filetype: A string indicating the filetype; Defaults to None (type determined by file extension). force_upload: skip the MD5 shortcut path, force an upload+analysis
Example:
>>> t = track.track_from_filename("Miaow-01-Tempered-song.mp3")
>>> t
< Track >
>>>
static track.track_from_url(url, timeout=60)

Create a track object from a public http URL.

Args:
url: A string giving the URL to read from. This must be on a public machine accessible by HTTP.
Example:
>>> t = track.track_from_url("http://www.miaowmusic.com/mp3/Miaow-01-Tempered-song.mp3")
>>> t
< Track >
>>>
static track.track_from_id(identifier, timeout=60)

Create a track object from an Echo Nest track ID.

Args:
identifier: A string containing the ID of a previously analyzed track.
Example:
>>> t = track.track_from_id("TRWFIDS128F92CC4CA")
>>> t
<track - Let The Spirit>
>>>
static track.track_from_md5(md5, timeout=60)

Create a track object from an md5 hash.

Args:
md5: A string 32 characters long giving the md5 checksum of a track already analyzed.
Example:
>>> t = track.track_from_md5('b8abf85746ab3416adabca63141d8c2d')
>>> t
<track - Neverwas Restored (from Neverwas Soundtrack)>
>>>

Previous topic

Song – song methods

Next topic

Playlist – playlist methods

This Page