Spotify-搜索曲目中的无声 [英] Spotify - searching for silences in a track

查看:225
本文介绍了Spotify-搜索曲目中的无声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直到处搜索,但没有找到关于Spotify APIanalysis_url audio feature的任何文档,以加深我对该主题的理解.

I have been searching everywhere but haven't found any documentation about the analysis_url audio feature on Spotify API, in order to deepen my understanding on the subject.

就我而言,它通过segmentsbarsbeatssample ratesfade ins and outskeystimbremodetempo

As far as I'm concerned, it learns the audio by segments, bars, beats, sample rates, fade ins and outs, keys, timbre, mode, time_signature, tempoetc

我到目前为止所拥有的是:

what I have so far is:

def analysis_url(track_ids):

    names = []
    tids = []

    for id_ in track_ids:
        track_id = sp.track(id_)['uri']
        tids.append(track_id)
        track_name = sp.track(id_)['name']
        names.append(track_name)

    features = sp.audio_features(tids)

    urls = [x['analysis_url'] for x in features if x]

    for url in urls:
        analysis = sp._get(url)

我想做的是在曲目中找到静音,例如电子音乐中的掉落".

What I would like to do is find silences in a track, such as a 'drop' in electronic music.

如何使用analysis_url来做到这一点?

how can I do that using the analysis_url?

推荐答案

分析来自一家名为EchoNest的公司,该公司早些时候被Spotify收购.您可以在此处找到该文档.

Analysis comes from a company called EchoNest, which was bought by Spotify some time ago. You can find the documentation for the analysis here.

段中包含一个Loudness_max值,该值指示该特定音乐部分的相对响度(以db为单位).对歌曲中的这些值进行归一化,然后查找相对响度较低的片段:

Segments include a loudness_max value which indicates the relatively loudness of that specific section of music (in db). Normalize those values over the song and look for segments that have a low relative loudness:

def normalize_loudness(filename):
    d = json.load(open(filename, 'r'))
    x = [_['start'] for _ in d['segments']]
    l = [_['loudness_max'] for _ in d['segments']]
    min_l = min(l)
    max_l = max(l)
    norm_l = [(_ - min_l)/(max_l - min_l) for _ in l]
    return (x, norm_l)

在Panic的歌曲杰克逊小姐"中使用它!在The Disco,我们可以绘制归一化的响度值:

Using this on the song "Miss Jackson" by Panic! At The Disco, we can plot the normalized loudness values:

import json
from matplotlib import pyplot as pp

x, norm_l = normalize_loudness('msJackson.json')
pp.plot(x, norm_l, 'o')
pp.show()
exit()

屈服:

您可以轻松地找到音乐中的低点:

With that you can easily find the low spots in the music:

print([x[i] for i in range(len(x)) if norm_l[i] < .1])
[0.0, 165.86036]

这篇关于Spotify-搜索曲目中的无声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆