def test_include_running_time(self): args = { 'input': ["tests/dummy/soundscape_good.wav", "tests/dummy/folder/"], 'output': "tests/output/", 'separate_results': False, 'running_time': True, 'verbose': False } success = run(args) self.assertTrue(success) expected_files = [ "soundscape_good.wav", "soundscape_x0.wav", "soundscape_x1.wav" ] with open(args['output'] + "results.txt", newline="\r\n") as file: output = file.read() # Assert output format try: lines = output.split("\r\n") for line in lines: if line != "\n": split_line = line.split("\t") expected_files.remove(split_line[0]) float(split_line[1]) # noise rating float(split_line[2]) # running time self.assertTrue( expected_files == []) # check all expected files seen except: self.fail()
def test_include_running_time_separate(self): args = { 'input': ["tests/dummy/soundscape_good.wav", "tests/dummy/folder/"], 'output': "tests/output/", 'separate_results': True, 'running_time': True, 'verbose': False } success = run(args) self.assertTrue(success) expected_files = [ "soundscape_good.txt", "soundscape_x0.txt", "soundscape_x1.txt" ] # Assert output format for file in expected_files: output_filename = args['output'] + file self.assertTrue(os.path.exists(output_filename)) with open(output_filename, newline="\r\n") as file: output = file.read().split("\t") try: float(output[0]) # noise rating float(output[1]) # running time except: self.fail()
def test_input_output(self): args = { 'input': ["tests/dummy/soundscape_good.wav"], 'output': "tests/output/", 'separate_results': False, 'running_time': False, 'verbose': False } success = run(args) self.assertTrue(success) self.assertTrue(os.path.exists(args['output']))
def test_input_missing(self): args = {} with self.assertRaises(ValueError): run(args)
help='folder in which the output file(s) should be stored') parser.add_argument( '--separate_results', '-sep', action='store_true', help='whether to put the results in separate text files') parser.add_argument( '--running_time', '-rt', action='store_true', help='whether to include the running time (in ms) in the output') parser.add_argument('--verbose', '-v', action='store_true', help='whether to print intermediate steps') args = parser.parse_args() try: # Add / to end of output folder name args.output = args.output if args.output.endswith( "/") else args.output + "/" except: args.output = os.getcwd( ) + "/" # if output folder not set, then define output as the current working directory run(args) # run HowNoisy pipeline with given command line arguments