2016-06-28 24 views
4

我最近發現了GNSDK(Gracenote SDK),它似乎提供了幾種編程語言的示例,通過指紋識別音樂樣本,然後請求其音頻數據庫獲取相應的藝術家和歌曲標題。如何使用Python和Gracenote識別音樂樣本?

但文件是可怕的。

我如何使用Python和GNSDK執行音頻樣本文件的識別?所提供的文檔中沒有任何示例或教程。

編輯:我真的想在Python中使用GNSDK。不要發佈任何不相關的東西,你會浪費你的時間。

回答

2

我結束了使用ACRCloud這工作得很好。似乎每個想要使用Gracenote的人都會回到ACRCloud,原因是......現在我知道爲什麼。

Python的例子:

from acrcloud.recognizer import ACRCloudRecognizer 

config = { 
    'host': 'eu-west-1.api.acrcloud.com', 
    'access_key': 'access key', 
    'access_secret': 'secret key', 
    'debug': True, 
    'timeout': 10 
} 

acrcloud = ACRCloudRecognizer(config) 

print(acrcloud.recognize_by_file('sample of a track.wav', 0)) 
2

關鍵詞是:擊敗頻譜分析和節奏檢測。

這是一個衆所周知的Python庫可以包含你的問題的解決方案: https://github.com/aubio/aubio

此外,我建議你應該檢查這個網頁,其他庫: https://wiki.python.org/moin/PythonInMusic

最後這個項目更多的Python友好溶液和容易的方式開始: https://github.com/librosa/librosa

一例從Librosa來計算速度(二每分鐘吃)的歌曲:

# Beat tracking example 
from __future__ import print_function 
import librosa 

# 1. Get the file path to the included audio example 
filename = librosa.util.example_audio_file() 

# 2. Load the audio as a waveform `y` 
# Store the sampling rate as `sr` 
y, sr = librosa.load(filename) 

# 3. Run the default beat tracker 
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr) 

print('Estimated tempo: {:.2f} beats per minute'.format(tempo)) 

# 4. Convert the frame indices of beat events into timestamps 
beat_times = librosa.frames_to_time(beat_frames, sr=sr) 

print('Saving output to beat_times.csv') 
librosa.output.times_csv('beat_times.csv', beat_times) 

但我不得不提到這個領域是計算機科學和每次非常不成熟領域的新論文出現了點。所以如果你也跟隨學者尋找最近的發現,這對你會有幫助。

此外:

在Gracenote的官方文檔提到的Web API封裝器: https://developer.gracenote.com/web-api#python

對於Python:

https://github.com/cweichen/pygn

但是你可以看到這個包裝是不是有據可查,不成熟。因此,我建議你使用這個Ruby包裝器代替Python;

爲Ruby:

https://github.com/JDiPierro/tmsapi

require 'tmsapi' 

# Create Instace of the API 
tms = TMSAPI::API.new :api_key => 'API_KEY_HERE' 

# Get all movie showtimes for Austin Texas 
movie_showings = tms.movies.theatres.showings({ :zip => "78701" }) 

# Print out the movie name, theatre name, and date/time of the showing. 
movie_showings.each do |movie| 
    movie.showtimes.each do |showing| 
    puts "#{movie.title} is playing at '#{showing.theatre.name}' at #{showing.date_time}." 
    end 
end 

# 12 Years a Slave is playing at 'Violet Crown Cinema' at 2013-12-23T12:45. 
# A Christmas Story is playing at 'Alamo Drafthouse at the Ritz' at 2013-12-23T16:00. 
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T11:00. 
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T13:40. 
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T16:20. 
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T19:00. 
# American Hustle is playing at 'Violet Crown Cinema' at 2013-12-23T21:40. 

如果你不熟悉Ruby或Ruby on Rails的那麼唯一的選擇就是開發自己的Python包裝。

+0

謝謝您的回答,但我說的是Python示例使用GNSDK :) – Epoc

+0

@Epoc我已經更新我的答案。請看一下。 – mertyildiran

+1

再次感謝您的補充,但您正在談論他們的Web API。 GNSDK與他們的Web API沒有直接關係。我想用Python中的GNSDK來計算音樂樣本的音頻指紋,然後請求他們的音頻數據庫獲取藝術家和音樂標題。這可以使用其他語言,但我的興趣是Python。 – Epoc

1

只是讀你的標題問題,因爲沒有對GNSDK例子或教程,嘗試尋找其他的選擇,
一:

DEJAVU

音頻指紋和識別算法實現在Python中, 請參閱此處的說明:

Dejavu可以通過聆聽一次和指紋012來記憶音頻吧。然後,通過播放歌曲和錄製麥克風輸入,Dejavu 嘗試將音頻與 數據庫中的指紋相匹配,並返回正在播放的歌曲。

https://github.com/worldveil/dejavu

似乎是正確的。

+0

dejavu非常適合通過託管創建音頻指紋數據庫。我的目標是使用Python的GNSDK通過請求他們的音頻數據庫來執行音樂識別 - 這可能與其他語言有關。 – Epoc

+0

結帳https://github.com/chewcode/gracenote-cli –