Exemple #1
0
def main():
    for label, genre in enumerate(GENRE_LIST):
        for fn in glob.glob(os.path.join(GENRE_DIR, genre)):
            for wavfile in os.listdir(fn):
                if wavfile.endswith("wav"):
                    print(genre)
                    create_ceps(os.path.join(GENRE_DIR, genre, wavfile))
def main():

    for label, dialect in enumerate(DIALECT_LIST):
        for fn in glob.glob(os.path.join(DIALECT_DIR, dialect)):
            for wavfile in os.listdir(fn):
                if wavfile.endswith("wav"):
                    create_ceps(os.path.join(DIALECT_DIR, dialect, wavfile))
Exemple #3
0
def main_function(docName):
    '''

	docName is the string which tells the name of the file to be downloaded.

	Returns :

	1. Success message
	2. full file location (to download later) 

	'''

    for wavfile in os.listdir(MEDIA_ROOT):
        if wavfile.endswith("wav"):
            if wavfile == docName:

                # for FFT Features :
                create_fft(os.path.join(MEDIA_ROOT + wavfile))

                # for MFCC Features :
                #create_ceps(os.path.join(MEDIA_ROOT + wavfile))

                # for STFT Features :
                #create_stft_feature(os.path.join(MEDIA_ROOT + wavfile))

                # for DWT Features :
                #create_dwt_feature(os.path.join(MEDIA_ROOT + wavfile))

                # for FFT :
                df_feature_1 = pd.DataFrame(function_dict_1)

                # for MFCC :
                df_feature_2 = pd.DataFrame(function_dict_2)

                # for STFT :
                df_feature_3 = pd.DataFrame(function_dict_3).astype(str)

                # for DWT :
                df_feature_4 = pd.DataFrame(function_dict_4)

                # combining them all :
                df = pd.concat(
                    [df_feature_1, df_feature_2, df_feature_3, df_feature_4],
                    ignore_index=False,
                    axis=1)

                #print(df.head())

                # to get the file name.
                base_fn, ext = os.path.splitext(wavfile)
                fname = base_fn + ".xlsx"

                full_file_loc = MEDIA_ROOT + 'convFiles/' + fname

                writer = ExcelWriter(full_file_loc)
                df.to_excel(writer, 'Sheet1', index=False)
                writer.save()

                return ("File " + fname + " created!", full_file_loc)
Exemple #4
0
import sys
import os
import scipy.io.wavfile
import scipy.signal
import matplotlib.pyplot as plt
# from matplotlib.pyplot import specgram 

os.chdir(sys.argv[1])
# Directory provided as a command line argument will be opened to visualize the files inside
wavfiles = []
for wavfile in os.listdir(sys.argv[1]):
    if wavfile.endswith("wav"):
        wavfiles.append(wavfile)

	

wavfiles.sort()

# Declare sampling rates and song arrays for each arg
sampling_rates = []
song_arrays = []

# Read wavfiles
for wavfile in wavfiles:
	sampling_rate, song_array = scipy.io.wavfile.read(wavfile)
	sampling_rates.append(sampling_rate)
	song_arrays.append(song_array)


i = 1  # plot number
# Plot spectrogram for each wave_file