Added sox as dependency in docs. Updated symlinking to allow symlinks to be overwritten by hard copies of files.
This commit is contained in:
@@ -15,6 +15,11 @@ modpath = sys.argv[0]
|
||||
modpath = os.path.splitext(modpath)[0]+'.log'
|
||||
|
||||
class SmartFormatter(argparse.HelpFormatter):
|
||||
"""
|
||||
Allows new line to be used in certain help strings.
|
||||
|
||||
Ref: http://stackoverflow.com/questions/3853722/python-argparse-how-to-insert-newline-in-the-help-text
|
||||
"""
|
||||
|
||||
def _split_lines(self, text, width):
|
||||
# this is the RawTextHelpFormatter._split_lines
|
||||
@@ -58,9 +63,14 @@ def parse_arguments():
|
||||
Parses arguments
|
||||
Returns a namespace with values for each argument
|
||||
"""
|
||||
# TODO: Write program description.
|
||||
parser = argparse.ArgumentParser(
|
||||
description='',
|
||||
description='Concatenator is a tool for synthesizing interpretations of '
|
||||
'a sound, through the analysis and synthesis of audio grains from a '
|
||||
'corpus database. The program works by analysing overlapping segments of '
|
||||
'audio (known as grains) from both the target sound and the source '
|
||||
'database, then searching for the closest matching grain in the source '
|
||||
'database to the target sound. Finally, the output is generated by '
|
||||
'overlap-adding the best matches.',
|
||||
formatter_class=SmartFormatter
|
||||
)
|
||||
|
||||
@@ -175,6 +185,14 @@ def parse_arguments():
|
||||
help="This flag enables scaling of matched grains to better match the target's volume."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--copy",
|
||||
action="store_true",
|
||||
help="This flag enables the copying of audio files from their location "
|
||||
"to the database, rather than creating symbolic links. This is useful "
|
||||
"for creating portable databases."
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--match_method",
|
||||
type=str,
|
||||
@@ -193,6 +211,9 @@ def parse_arguments():
|
||||
if args.match_method:
|
||||
config.matcher["method"] = args.match_method
|
||||
|
||||
if args.copy:
|
||||
config.database["symlink"] = False
|
||||
|
||||
if args.rematch:
|
||||
config.matcher["rematch"] = True
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ fft = {
|
||||
"window_size": 65536
|
||||
}
|
||||
|
||||
database = {
|
||||
# Enables creation of symbolic links to files not in the database rather
|
||||
# than making pysical copies.
|
||||
"symlink": True
|
||||
}
|
||||
|
||||
matcher_weightings = {
|
||||
"f0" : 1.,
|
||||
|
||||
@@ -116,7 +116,7 @@ class AudioDatabase:
|
||||
if not os.path.exists(self.audio_dir):
|
||||
raise IOError("The audio directory provided ({0}) doesn't "
|
||||
"exist".format(self.audio_dir))
|
||||
self.organize_audio(subdir_paths)
|
||||
self.organize_audio(subdir_paths, symlink=self.config.database["symlink"])
|
||||
|
||||
self.analyse_database(subdir_paths, reanalyse)
|
||||
|
||||
@@ -268,13 +268,27 @@ class AudioDatabase:
|
||||
self.logger.info(''.join(("Linked: ", item, "\tTo directory: ",
|
||||
subdir_paths["audio"], "\n")))
|
||||
else:
|
||||
try:
|
||||
os.unlink(destination)
|
||||
except OSError:
|
||||
pass
|
||||
shutil.copy2(filepath, subdir_paths["audio"])
|
||||
self.logger.info(''.join(("Moved: ", item, "\tTo directory: ",
|
||||
self.logger.info(''.join(("Copied: ", item, "\tTo directory: ",
|
||||
subdir_paths["audio"], "\n")))
|
||||
|
||||
else:
|
||||
self.logger.info(''.join(("File: ", item, "\tAlready exists at: ",
|
||||
subdir_paths["audio"])))
|
||||
if not symlink:
|
||||
try:
|
||||
linkpath = os.readlink(destination)
|
||||
os.unlink(destination)
|
||||
except OSError:
|
||||
continue
|
||||
shutil.copy2(linkpath, subdir_paths["audio"])
|
||||
self.logger.info(''.join(("Copied: ", item, "\tTo directory: ",
|
||||
subdir_paths["audio"], "\n")))
|
||||
else:
|
||||
self.logger.info(''.join(("File: ", item, "\tAlready exists at: ",
|
||||
subdir_paths["audio"])))
|
||||
# Add the file's path to the database content dictionary
|
||||
self.audio_file_list.add(
|
||||
os.path.join(subdir_paths["audio"], os.path.basename(item))
|
||||
|
||||
@@ -50,6 +50,7 @@ libsndfile and HDF5 libraries can also be installed via homebrew/linuxbrew:
|
||||
brew install libsndfile
|
||||
brew tap homebrew/science
|
||||
brew install hdf5
|
||||
brew install sox
|
||||
|
||||
Python library and dependencies installation
|
||||
--------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user