Module Import alias Import alias Import alias Import alias identifier Import alias Import alias ImportFrom alias alias Import alias identifier ImportFrom alias FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore BinOpAdd NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Print BinOpMod Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign NameStore Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Slice Num Expr Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Assign NameStore ListLoad Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assert NameLoad NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Num Expr Call AttributeLoad NameLoad attr NameLoad Return TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword TupleLoad Num Num Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad NameLoad BinOpDiv Num NameLoad Expr Call AttributeLoad NameLoad attr Num Assign NameStore Num Expr Call AttributeLoad NameLoad attr Num BinOpDiv NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr BoolOpOr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr NameLoad NameLoad SubscriptLoad NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Num Num Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr BinOpMult Call AttributeLoad NameLoad attr Num Num If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd Call AttributeLoad SubscriptLoad NameLoad Index Num attr SubscriptLoad NameLoad Slice Num orelse Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Call NameLoad NameLoad keyword Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Index Num Expr Call AttributeLoad NameLoad attr BinOpMod Str SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Index Num keyword Str Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Expr Call NameLoad Str Str Expr Call NameLoad Str Str Expr Call NameLoad Str Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword TupleLoad Num Num decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Assign NameStore ListLoad Str Str Str Str Str Str Assign NameStore Num Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body For TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Str body If CompareEq NameLoad NameLoad body Break Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad BinOpAdd NameLoad Num Expr Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad keyword Str Expr Call AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body If CompareGt Call NameLoad AttributeLoad NameLoad attr Num body Expr Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num keyword Str orelse Expr Call NameLoad Expr Call NameLoad
N/A N/A sys N/A os N/A glob N/A numpy np N/A scipy N/A scipy.io.wavfile utils GENRE_DIR CHART_DIR N/A matplotlib.pyplot plt matplotlib.ticker EngFormatter write_fft N/A N/A fft_features fn N/A N/A N/A 
    Write the FFT features to separate files to speed up processing.
     N/A N/A base_fn ext N/A N/A N/A os path splitext fn N/A data_fn N/A base_fn .fft N/A N/A N/A np save data_fn fft_features N/A N/A Written  data_fn N/A create_fft N/A N/A fn N/A N/A N/A N/A sample_rate X N/A N/A N/A N/A scipy io wavfile read fn N/A fft_features N/A abs N/A N/A N/A scipy fft X N/A 1000 N/A N/A write_fft fft_features fn N/A read_fft N/A N/A genre_list base_dir N/A GENRE_DIR N/A N/A X N/A N/A y N/A N/A N/A label genre N/A enumerate genre_list N/A N/A genre_dir N/A N/A N/A os path join base_dir genre *.fft.npy N/A file_list N/A N/A glob glob genre_dir N/A file_list genre_dir N/A fn file_list N/A N/A fft_features N/A N/A np load fn N/A N/A N/A X append N/A fft_features N/A 2000 N/A N/A N/A y append label N/A N/A N/A N/A np array X N/A N/A np array y N/A plot_wav_fft N/A N/A wav_filename desc N/A None N/A N/A N/A N/A plt clf N/A N/A N/A plt figure num None figsize N/A 6 4 N/A N/A sample_rate X N/A N/A N/A N/A scipy io wavfile read wav_filename N/A spectrum N/A N/A N/A np fft fft X N/A freq N/A N/A N/A np fft fftfreq N/A len X N/A 1.0 sample_rate N/A N/A N/A plt subplot 211 N/A num_samples 200.0 N/A N/A N/A plt xlim 0 N/A num_samples sample_rate N/A N/A N/A plt xlabel time [s] N/A N/A N/A plt title N/A desc wav_filename N/A N/A N/A plt plot N/A N/A N/A np arange num_samples sample_rate N/A X N/A num_samples N/A N/A N/A plt grid True N/A N/A N/A plt subplot 212 N/A N/A N/A plt xlim 0 5000 N/A N/A N/A plt xlabel frequency [Hz] N/A N/A N/A plt xticks N/A N/A N/A np arange 5 1000 N/A desc N/A N/A desc N/A N/A desc strip N/A fft_desc N/A N/A N/A N/A desc N/A 0 lower N/A desc N/A 1 N/A N/A fft_desc wav_filename N/A N/A N/A plt title N/A FFT of %s fft_desc N/A N/A N/A plt plot freq N/A abs spectrum linewidth 5 N/A N/A N/A plt grid True N/A N/A N/A plt tight_layout N/A rel_filename N/A N/A N/A N/A os path split wav_filename N/A 1 N/A N/A N/A plt savefig N/A %s_wav_fft.png N/A N/A N/A N/A os path splitext rel_filename N/A 0 bbox_inches tight N/A N/A N/A plt show N/A plot_wav_fft_demo N/A N/A N/A N/A N/A N/A plot_wav_fft sine_a.wav 400Hz sine wave N/A N/A plot_wav_fft sine_b.wav 3,000Hz sine wave N/A N/A plot_wav_fft sine_mix.wav Mixed sine wave N/A plot_specgram N/A N/A ax fn N/A N/A N/A N/A sample_rate X N/A N/A N/A N/A scipy io wavfile read fn N/A N/A N/A ax specgram X Fs sample_rate xextent N/A 0 30 N/A plot_specgrams N/A N/A base_dir N/A CHART_DIR N/A N/A 
    Plot a bunch of spectrograms of wav files in different genres
     N/A N/A N/A plt clf N/A genres N/A classical jazz country pop rock metal N/A num_files 3 N/A N/A f axes N/A N/A plt subplots N/A len genres num_files N/A N/A genre_idx genre N/A enumerate genres N/A N/A N/A idx fn N/A enumerate N/A N/A glob glob N/A N/A N/A os path join GENRE_DIR genre *.wav N/A N/A N/A idx num_files N/A N/A N/A axis N/A axes N/A N/A genre_idx idx N/A N/A N/A N/A axis yaxis set_major_formatter N/A EngFormatter N/A N/A N/A axis set_title N/A %s song %i N/A genre N/A idx 1 N/A N/A plot_specgram axis fn N/A specgram_file N/A N/A N/A os path join base_dir Spectrogram_Genres.png N/A N/A N/A plt savefig specgram_file bbox_inches tight N/A N/A N/A plt show N/A N/A N/A __name__ __main__ N/A N/A N/A N/A len N/A sys argv 1 N/A N/A N/A plot_wav_fft N/A N/A sys argv N/A 1 desc some sample song N/A N/A N/A plot_wav_fft_demo N/A N/A plot_specgrams