{"action":"created","comment":{"url":"https://api.github.com/repos/fchollet/keras/pulls/comments/80352754","id":80352754,"diff_hunk":"@@ -0,0 +1,81 @@\n+import numpy as np\n+from .. import backend as K\n+\n+if librosa_exists():\n+    import librosa\n+else:\n+    raise RuntimeError('librosa is required to process audio files\\n' +\n+                       'In short, $ pip install librosa\\nor visit ' +\n+                       'http://librosa.github.io/librosa/ for details.')\n+\n+TAGS = ['rock', 'pop', 'alternative', 'indie', 'electronic',\n+        'female vocalists', 'dance', '00s', 'alternative rock', 'jazz',\n+        'beautiful', 'metal', 'chillout', 'male vocalists',\n+        'classic rock', 'soul', 'indie rock', 'Mellow', 'electronica',\n+        '80s', 'folk', '90s', 'chill', 'instrumental', 'punk',\n+        'oldies', 'blues', 'hard rock', 'ambient', 'acoustic',\n+        'experimental', 'female vocalist', 'guitar', 'Hip-Hop',\n+        '70s', 'party', 'country', 'easy listening',\n+        'sexy', 'catchy', 'funk', 'electro', 'heavy metal',\n+        'Progressive rock', '60s', 'rnb', 'indie pop',\n+        'sad', 'House', 'happy']\n+\n+\n+def librosa_exists():\n+    try:\n+        __import__('librosa')\n+    except ImportError:\n+        return False\n+    else:\n+        return True\n+\n+\n+def load_preprocess_input(audio_path, dim_ordering='default'):\n+    if dim_ordering == 'default':\n+        dim_ordering = K.image_dim_ordering()\n+    assert dim_ordering in {'tf', 'th'}\n+\n+    # mel-spectrogram parameters\n+    SR = 12000\n+    N_FFT = 512\n+    N_MELS = 96\n+    HOP_LEN = 256\n+    DURA = 29.12\n+\n+    src, sr = librosa.load(audio_path, sr=SR)\n+    n_sample = src.shape[0]\n+    n_sample_wanted = int(DURA*SR)\n+\n+    # trim the signal at the center\n+    if n_sample < n_sample_wanted:  # if too short\n+        src = np.hstack((src, np.zeros((int(DURA*SR) - n_sample,))))\n+    elif n_sample > n_sample_wanted:  # if too long\n+        src = src[(n_sample-n_sample_wanted)/2:(n_sample+n_sample_wanted)/2]\n+\n+    logam = librosa.logamplitude\n+    melgram = librosa.feature.melspectrogram\n+    x = logam(melgram(y=src, sr=SR, hop_length=HOP_LEN,\n+                      n_fft=N_FFT, n_mels=N_MELS)**2,","path":"keras/applications/audio_conv_utils.py","position":58,"original_position":58,"commit_id":"6cadc7bd4f46d0776e5b27518aedd5b2811cef04","original_commit_id":"6cadc7bd4f46d0776e5b27518aedd5b2811cef04","user":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"body":"PEP8","created_at":"2016-09-24T04:27:18Z","updated_at":"2016-09-24T04:28:09Z","html_url":"https://github.com/fchollet/keras/pull/3718#discussion_r80352754","pull_request_url":"https://api.github.com/repos/fchollet/keras/pulls/3718","_links":{"self":{"href":"https://api.github.com/repos/fchollet/keras/pulls/comments/80352754"},"html":{"href":"https://github.com/fchollet/keras/pull/3718#discussion_r80352754"},"pull_request":{"href":"https://api.github.com/repos/fchollet/keras/pulls/3718"}}},"pull_request":{"url":"https://api.github.com/repos/fchollet/keras/pulls/3718","id":84428946,"html_url":"https://github.com/fchollet/keras/pull/3718","diff_url":"https://github.com/fchollet/keras/pull/3718.diff","patch_url":"https://github.com/fchollet/keras/pull/3718.patch","issue_url":"https://api.github.com/repos/fchollet/keras/issues/3718","number":3718,"state":"open","locked":false,"title":"add audio models: audio_convnet and audio_conv_rnn","user":{"login":"keunwoochoi","id":16153797,"avatar_url":"https://avatars.githubusercontent.com/u/16153797?v=3","gravatar_id":"","url":"https://api.github.com/users/keunwoochoi","html_url":"https://github.com/keunwoochoi","followers_url":"https://api.github.com/users/keunwoochoi/followers","following_url":"https://api.github.com/users/keunwoochoi/following{/other_user}","gists_url":"https://api.github.com/users/keunwoochoi/gists{/gist_id}","starred_url":"https://api.github.com/users/keunwoochoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keunwoochoi/subscriptions","organizations_url":"https://api.github.com/users/keunwoochoi/orgs","repos_url":"https://api.github.com/users/keunwoochoi/repos","events_url":"https://api.github.com/users/keunwoochoi/events{/privacy}","received_events_url":"https://api.github.com/users/keunwoochoi/received_events","type":"User","site_admin":false},"body":".h5 files are now at https://github.com/keunwoochoi/music-auto_tagging-keras/tree/master/data.\r\n","created_at":"2016-09-08T07:40:53Z","updated_at":"2016-09-24T04:28:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eae9874bfe58dc36fed4e66bc6dfc13f48271001","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/fchollet/keras/pulls/3718/commits","review_comments_url":"https://api.github.com/repos/fchollet/keras/pulls/3718/comments","review_comment_url":"https://api.github.com/repos/fchollet/keras/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fchollet/keras/issues/3718/comments","statuses_url":"https://api.github.com/repos/fchollet/keras/statuses/6cadc7bd4f46d0776e5b27518aedd5b2811cef04","head":{"label":"keunwoochoi:master","ref":"master","sha":"6cadc7bd4f46d0776e5b27518aedd5b2811cef04","user":{"login":"keunwoochoi","id":16153797,"avatar_url":"https://avatars.githubusercontent.com/u/16153797?v=3","gravatar_id":"","url":"https://api.github.com/users/keunwoochoi","html_url":"https://github.com/keunwoochoi","followers_url":"https://api.github.com/users/keunwoochoi/followers","following_url":"https://api.github.com/users/keunwoochoi/following{/other_user}","gists_url":"https://api.github.com/users/keunwoochoi/gists{/gist_id}","starred_url":"https://api.github.com/users/keunwoochoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keunwoochoi/subscriptions","organizations_url":"https://api.github.com/users/keunwoochoi/orgs","repos_url":"https://api.github.com/users/keunwoochoi/repos","events_url":"https://api.github.com/users/keunwoochoi/events{/privacy}","received_events_url":"https://api.github.com/users/keunwoochoi/received_events","type":"User","site_admin":false},"repo":{"id":47941318,"name":"keras","full_name":"keunwoochoi/keras","owner":{"login":"keunwoochoi","id":16153797,"avatar_url":"https://avatars.githubusercontent.com/u/16153797?v=3","gravatar_id":"","url":"https://api.github.com/users/keunwoochoi","html_url":"https://github.com/keunwoochoi","followers_url":"https://api.github.com/users/keunwoochoi/followers","following_url":"https://api.github.com/users/keunwoochoi/following{/other_user}","gists_url":"https://api.github.com/users/keunwoochoi/gists{/gist_id}","starred_url":"https://api.github.com/users/keunwoochoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keunwoochoi/subscriptions","organizations_url":"https://api.github.com/users/keunwoochoi/orgs","repos_url":"https://api.github.com/users/keunwoochoi/repos","events_url":"https://api.github.com/users/keunwoochoi/events{/privacy}","received_events_url":"https://api.github.com/users/keunwoochoi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/keunwoochoi/keras","description":"Deep Learning library for Python. Convnets, recurrent neural networks, and more. Runs on Theano and TensorFlow.","fork":true,"url":"https://api.github.com/repos/keunwoochoi/keras","forks_url":"https://api.github.com/repos/keunwoochoi/keras/forks","keys_url":"https://api.github.com/repos/keunwoochoi/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keunwoochoi/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keunwoochoi/keras/teams","hooks_url":"https://api.github.com/repos/keunwoochoi/keras/hooks","issue_events_url":"https://api.github.com/repos/keunwoochoi/keras/issues/events{/number}","events_url":"https://api.github.com/repos/keunwoochoi/keras/events","assignees_url":"https://api.github.com/repos/keunwoochoi/keras/assignees{/user}","branches_url":"https://api.github.com/repos/keunwoochoi/keras/branches{/branch}","tags_url":"https://api.github.com/repos/keunwoochoi/keras/tags","blobs_url":"https://api.github.com/repos/keunwoochoi/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keunwoochoi/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keunwoochoi/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/keunwoochoi/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keunwoochoi/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/keunwoochoi/keras/languages","stargazers_url":"https://api.github.com/repos/keunwoochoi/keras/stargazers","contributors_url":"https://api.github.com/repos/keunwoochoi/keras/contributors","subscribers_url":"https://api.github.com/repos/keunwoochoi/keras/subscribers","subscription_url":"https://api.github.com/repos/keunwoochoi/keras/subscription","commits_url":"https://api.github.com/repos/keunwoochoi/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/keunwoochoi/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/keunwoochoi/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/keunwoochoi/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/keunwoochoi/keras/contents/{+path}","compare_url":"https://api.github.com/repos/keunwoochoi/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keunwoochoi/keras/merges","archive_url":"https://api.github.com/repos/keunwoochoi/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keunwoochoi/keras/downloads","issues_url":"https://api.github.com/repos/keunwoochoi/keras/issues{/number}","pulls_url":"https://api.github.com/repos/keunwoochoi/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/keunwoochoi/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/keunwoochoi/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keunwoochoi/keras/labels{/name}","releases_url":"https://api.github.com/repos/keunwoochoi/keras/releases{/id}","deployments_url":"https://api.github.com/repos/keunwoochoi/keras/deployments","created_at":"2015-12-13T23:36:53Z","updated_at":"2016-08-18T05:17:18Z","pushed_at":"2016-09-23T22:21:07Z","git_url":"git://github.com/keunwoochoi/keras.git","ssh_url":"git@github.com:keunwoochoi/keras.git","clone_url":"https://github.com/keunwoochoi/keras.git","svn_url":"https://github.com/keunwoochoi/keras","homepage":"http://keras.io/","size":4006,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fchollet:master","ref":"master","sha":"25874ceab26bd9e08e532c442dc845bccf0590d5","user":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"repo":{"id":33015583,"name":"keras","full_name":"fchollet/keras","owner":{"login":"fchollet","id":710255,"avatar_url":"https://avatars.githubusercontent.com/u/710255?v=3","gravatar_id":"","url":"https://api.github.com/users/fchollet","html_url":"https://github.com/fchollet","followers_url":"https://api.github.com/users/fchollet/followers","following_url":"https://api.github.com/users/fchollet/following{/other_user}","gists_url":"https://api.github.com/users/fchollet/gists{/gist_id}","starred_url":"https://api.github.com/users/fchollet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fchollet/subscriptions","organizations_url":"https://api.github.com/users/fchollet/orgs","repos_url":"https://api.github.com/users/fchollet/repos","events_url":"https://api.github.com/users/fchollet/events{/privacy}","received_events_url":"https://api.github.com/users/fchollet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fchollet/keras","description":"Deep Learning library for Python. Convnets, recurrent neural networks, and more. Runs on Theano or TensorFlow.","fork":false,"url":"https://api.github.com/repos/fchollet/keras","forks_url":"https://api.github.com/repos/fchollet/keras/forks","keys_url":"https://api.github.com/repos/fchollet/keras/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fchollet/keras/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fchollet/keras/teams","hooks_url":"https://api.github.com/repos/fchollet/keras/hooks","issue_events_url":"https://api.github.com/repos/fchollet/keras/issues/events{/number}","events_url":"https://api.github.com/repos/fchollet/keras/events","assignees_url":"https://api.github.com/repos/fchollet/keras/assignees{/user}","branches_url":"https://api.github.com/repos/fchollet/keras/branches{/branch}","tags_url":"https://api.github.com/repos/fchollet/keras/tags","blobs_url":"https://api.github.com/repos/fchollet/keras/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fchollet/keras/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fchollet/keras/git/refs{/sha}","trees_url":"https://api.github.com/repos/fchollet/keras/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fchollet/keras/statuses/{sha}","languages_url":"https://api.github.com/repos/fchollet/keras/languages","stargazers_url":"https://api.github.com/repos/fchollet/keras/stargazers","contributors_url":"https://api.github.com/repos/fchollet/keras/contributors","subscribers_url":"https://api.github.com/repos/fchollet/keras/subscribers","subscription_url":"https://api.github.com/repos/fchollet/keras/subscription","commits_url":"https://api.github.com/repos/fchollet/keras/commits{/sha}","git_commits_url":"https://api.github.com/repos/fchollet/keras/git/commits{/sha}","comments_url":"https://api.github.com/repos/fchollet/keras/comments{/number}","issue_comment_url":"https://api.github.com/repos/fchollet/keras/issues/comments{/number}","contents_url":"https://api.github.com/repos/fchollet/keras/contents/{+path}","compare_url":"https://api.github.com/repos/fchollet/keras/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fchollet/keras/merges","archive_url":"https://api.github.com/repos/fchollet/keras/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fchollet/keras/downloads","issues_url":"https://api.github.com/repos/fchollet/keras/issues{/number}","pulls_url":"https://api.github.com/repos/fchollet/keras/pulls{/number}","milestones_url":"https://api.github.com/repos/fchollet/keras/milestones{/number}","notifications_url":"https://api.github.com/repos/fchollet/keras/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fchollet/keras/labels{/name}","releases_url":"https://api.github.com/repos/fchollet/keras/releases{/id}","deployments_url":"https://api.github.com/repos/fchollet/keras/deployments","created_at":"2015-03-28T00:35:42Z","updated_at":"2016-09-24T04:20:01Z","pushed_at":"2016-09-24T04:16:19Z","git_url":"git://github.com/fchollet/keras.git","ssh_url":"git@github.com:fchollet/keras.git","clone_url":"https://github.com/fchollet/keras.git","svn_url":"https://github.com/fchollet/keras","homepage":"http://keras.io/","size":156724,"stargazers_count":8313,"watchers_count":8313,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2574,"mirror_url":null,"open_issues_count":1387,"forks":2574,"open_issues":1387,"watchers":8313,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fchollet/keras/pulls/3718"},"html":{"href":"https://github.com/fchollet/keras/pull/3718"},"issue":{"href":"https://api.github.com/repos/fchollet/keras/issues/3718"},"comments":{"href":"https://api.github.com/repos/fchollet/keras/issues/3718/comments"},"review_comments":{"href":"https://api.github.com/repos/fchollet/keras/pulls/3718/comments"},"review_comment":{"href":"https://api.github.com/repos/fchollet/keras/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fchollet/keras/pulls/3718/commits"},"statuses":{"href":"https://api.github.com/repos/fchollet/keras/statuses/6cadc7bd4f46d0776e5b27518aedd5b2811cef04"}}}}
{"actor":{"display_login":"fchollet"}}