ADTLib

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 58d60b367d7f811a61ee26684d8edf67093aaefa
parent 15c44af028bea6e4306b8d937d1fd6bcc364e7f5
Author: CarlSouthall <[email protected]>
Date:   Thu, 18 May 2017 13:18:38 +0100

Merge pull request #3 from Python3pkg/master

Convert to Python3
Diffstat:
MADTLib/__init__.py | 2+-
CADTLib/__init__.py -> ADTLib/__init__.py.bak | 0
MADTLib/models/__init__.py | 20++++++++++----------
CADTLib/models/__init__.py -> ADTLib/models/__init__.py.bak | 0
MADTLib/nn/__init__.py | 6+++---
CADTLib/nn/__init__.py -> ADTLib/nn/__init__.py.bak | 0
MADTLib/utils/__init__.py | 16++++++++--------
CADTLib/utils/__init__.py -> ADTLib/utils/__init__.py.bak | 0
8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/ADTLib/__init__.py b/ADTLib/__init__.py @@ -5,6 +5,6 @@ """ -from __future__ import absolute_import, division, print_function + from . import utils, nn, models diff --git a/ADTLib/__init__.py b/ADTLib/__init__.py.bak diff --git a/ADTLib/models/__init__.py b/ADTLib/models/__init__.py @@ -6,7 +6,7 @@ ADTBDRNN """ -from __future__ import absolute_import, division, print_function + import madmom import tensorflow as tf @@ -37,24 +37,24 @@ def ADTBDRNN(TrackNames, out_sort='time',ret='yes', out_text='no', savedir='curr names=list(np.zeros(len(TrackNames))) Track=list(np.zeros(len(TrackNames))) - for i in xrange(len(TrackNames)): + for i in range(len(TrackNames)): Track[i]=Wavread(TrackNames[i]) name=TrackNames[i].split('.wav') names[i]=name[0] Frames=list(np.zeros(len(Track))) Train=list(np.zeros(len(Track))) - for j in xrange(len(Track)): + for j in range(len(Track)): NFrames=int(np.ceil(len(Track[j])/float(HS))) Frames[j]=np.zeros((NFrames,WL)) - for i in xrange(NFrames): + for i in range(NFrames): Frames[j][i]=np.squeeze(madmom.audio.signal.signal_frame(Track[j],i,WL,HS,origin=-HS)) Spectrogram=madmom.audio.spectrogram.spec(madmom.audio.stft.stft(Frames[j],np.hanning(WL), fft_size=WL)) Train[j]=np.zeros((len(Spectrogram),Time_Steps,len(Spectrogram[0]))) - for i in xrange(len(Spectrogram)): - for k in xrange(Time_Steps): + for i in range(len(Spectrogram)): + for k in range(Time_Steps): if i-k >= 0: Train[j][i][Time_Steps-k-1]=Spectrogram[i-k,:] @@ -68,17 +68,17 @@ def ADTBDRNN(TrackNames, out_sort='time',ret='yes', out_text='no', savedir='curr AF=list(np.zeros(len(Track))) P=list(np.zeros(len(Track))) - for j in xrange(len(Track)): + for j in range(len(Track)): AF[j]=list([Kout[j][:,0],Sout[j][:,0],Hout[j][:,0]]) P[j]=list(np.zeros(3)) - for i in xrange(len(AF[j])): + for i in range(len(AF[j])): P[j][i]=MeanPP(AF[j][i],lambd[i]) x=np.sort(P[j][i]) peak=[] if len(x) > 0: peak=np.append(peak,x[0]) - for k in xrange(len(x)-1): + for k in range(len(x)-1): if (x[k+1]-peak[len(peak)-1]) >= close_error: peak=np.append(peak,x[k+1]) @@ -88,7 +88,7 @@ def ADTBDRNN(TrackNames, out_sort='time',ret='yes', out_text='no', savedir='curr if out_text == 'yes': write_text(P,names,save_dir=savedir) - for i in xrange(len(P)): + for i in range(len(P)): Pnew=list(np.zeros(2)) Pnew[0]=np.array(P[i][:,0],dtype=float) Pnew[1]=np.array(P[i][:,1],dtype=str) diff --git a/ADTLib/models/__init__.py b/ADTLib/models/__init__.py.bak diff --git a/ADTLib/nn/__init__.py b/ADTLib/nn/__init__.py @@ -2,7 +2,7 @@ """ @author: CarlSouthall """ -from __future__ import absolute_import, division, print_function + import numpy as np import tensorflow as tf from tensorflow.python.ops import rnn, rnn_cell @@ -11,7 +11,7 @@ def BDRNNRestoreAll(X, RestoreFileName, num_layers=3,Truncated=1,n_hidden=50,n_c tf.reset_default_graph() batch_size=0; - for i in xrange(len(X)): + for i in range(len(X)): if len(X[i]) > batch_size: batch_size=len(X[i]) @@ -57,7 +57,7 @@ def BDRNNRestoreAll(X, RestoreFileName, num_layers=3,Truncated=1,n_hidden=50,n_c sess.run(init) saver.restore(sess,RestoreFileName) - for i in xrange (len(Test)): + for i in range (len(Test)): test_len = len(Test[i]) if test_len != batch_size: e=np.zeros((batch_size-test_len,1,len(Test[i][0,0]))) diff --git a/ADTLib/nn/__init__.py b/ADTLib/nn/__init__.py.bak diff --git a/ADTLib/utils/__init__.py b/ADTLib/utils/__init__.py @@ -2,7 +2,7 @@ """ @author: CarlSouthall """ -from __future__ import absolute_import, division, print_function + import scipy.io.wavfile as wav import numpy as np import os @@ -13,7 +13,7 @@ def MeanPP(Track,Lambda): m=np.mean(Track)*Lambda onsets=[] Track=np.append(Track,0) - for i in xrange(len(Track)): + for i in range(len(Track)): if Track[i]>Track[i-1] and Track[i]>Track[i+1] and Track[i]> m: onsets=np.append(onsets,i) @@ -36,13 +36,13 @@ def arrange_output(Inputs,output_sort='time'): Out=list(np.zeros(len(Inputs))) Out1=list(np.zeros(len(Inputs))) - for i in xrange(len(Inputs)): + for i in range(len(Inputs)): Out[i]=list(np.zeros(len(Inputs[i]))) Out1[i]=list(np.zeros((1,2))) - for j in xrange(len(Inputs[i])): + for j in range(len(Inputs[i])): Out[i][j]=list(np.zeros((len(Inputs[i][j])))) - for k in xrange(len(Inputs[i][j])): + for k in range(len(Inputs[i][j])): Out[i][j][k]=list(np.zeros(2)) Out[i][j][k][0]=Inputs[i][j][k] Out[i][j][k][1]=Names[j] @@ -58,7 +58,7 @@ def arrange_output(Inputs,output_sort='time'): Out[i][:,0]=np.array(np.sort(Out1[i]),dtype=str) indexs=np.argsort(Out1[i]) out_names=list(Out[i][:,1]) - for j in xrange(len(indexs)): + for j in range(len(indexs)): Out[i][j,1]=out_names[indexs[j]] @@ -70,9 +70,9 @@ def write_text(X,names,suffix='.ADT.txt',save_dir='current'): current_dir=os.getcwd() os.chdir(save_dir) - for i in xrange(len(names)): + for i in range(len(names)): file = open(names[i]+suffix, "w") - for j in xrange(len(X[i])): + for j in range(len(X[i])): X[i][j][0]=X[i][j][0][0:8] item=" ".join(X[i][j]) file.write("%s\n" % item) diff --git a/ADTLib/utils/__init__.py b/ADTLib/utils/__init__.py.bak