def create_corpus(filepath, weights, chop): """ Create a directory callled corpus in the same directory as filepath, convert all the audio files, segment and analyse... ffmpeg must be installed for Mp3 conversion to work """ if os.path.isfile(filepath): cm = FileCorpusManager(os.path.dirname(filepath)) try: cm.create_corpus('corpus') except CorpusExistsException, e: cm.delete_corpus('corpus') cm.create_corpus('corpus') c = cm.load_corpus('corpus') shutil.copy(filepath, os.path.join(os.path.dirname(filepath), 'corpus', os.path.basename(filepath)))
cm = FileCorpusManager(os.path.dirname(filepath)) try: cm.create_corpus('corpus') except CorpusExistsException, e: cm.delete_corpus('corpus') cm.create_corpus('corpus') c = cm.load_corpus('corpus') shutil.copy(filepath, os.path.join(os.path.dirname(filepath), 'corpus', os.path.basename(filepath))) else: cm = FileCorpusManager(filepath) to_copy = os.listdir(cm.repository) try: cm.create_corpus('corpus') except CorpusExistsException, e: cm.delete_corpus('corpus') to_copy = os.listdir(cm.repository) cm.create_corpus('corpus') c = cm.load_corpus('corpus') os.chdir(cm.repository) for f in to_copy: shutil.copy(f, c.location) os.chdir(c.location) ca.rename_wavs() ca.execute_flac_convert() ca.execute_mp3_convert() if chop == 'onsets': for audio_file in c.list_audio_files():