Skip to content

Commit

Permalink
Add speechiness
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Sabo committed Nov 3, 2011
1 parent 5c462d9 commit 55b1626
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyechonest/track.py
Expand Up @@ -66,6 +66,8 @@ class Track(TrackProxy):
segments list of dicts: timing, pitch, loudness and timbre for each segment
speechiness float: relative speechiness (0 to 1)
start_of_fade_out float: time in seconds where fade out begins
status str: analysis status, e.g. 'complete', 'pending', 'error'
Expand Down Expand Up @@ -127,13 +129,16 @@ def _track_from_response(response):
audio_summary = track.pop('audio_summary')
energy = audio_summary.get('energy', 0)
danceability = audio_summary.get('danceability', 0)
speechiness = audio_summary.get('speechiness', 0)
json_url = audio_summary['analysis_url']
json_string = urllib2.urlopen(json_url).read()
analysis = json.loads(json_string)
nested_track = analysis.pop('track')
track.update(analysis)
track.update(nested_track)
track.update({'analysis_url': json_url, 'energy': energy, 'danceability': danceability})
track.update({'analysis_url': json_url, 'energy': energy,
'danceability': danceability,
'speechiness': speechiness})
return Track(identifier, md5, track)

def _upload(param_dict, data = None):
Expand Down

0 comments on commit 55b1626

Please sign in to comment.