### Run Voicelab node from command line using prepare_node() and process() Source: https://voice-lab.github.io/VoiceLab These functions form the test harness for the ReverseSoundsNode. They set up test files, prepare the node with a sound file, generate reversed validation sounds, and run the node's process() method to compare results. The final test uses pytest parametrization to iterate over all test files except the first broken one. ```python # Arrange def get_test_files(): number_of_test_files = len(os.listdir(AUDIO_DIR)) - 1 # -1 because the first file is a broken sound test_files = sorted(os.listdir(AUDIO_DIR))[1:] return number_of_test_files, test_files ``` ```python # Arrange def prepare_node(test_file): file_path = os.path.join(AUDIO_DIR, test_file) node = ReverseSoundsNode.ReverseSoundsNode() node.args['file_path'] = file_path # Load the sound and setup the node try: sound: parselmouth.Sound = parselmouth.Sound(file_path) signal = sound.values sampling_rate = sound.sampling_frequency except: signal = None sampling_rate = None node.voice = (signal, sampling_rate) node.args['voice'] = (signal, sampling_rate) print((f"{file_path=}..{sampling_rate=}")) return node ``` ```python # Arrange def get_reversed_test_sound(test_file): file_path = os.path.join(AUDIO_DIR, test_file) validation_sound = parselmouth.Sound(file_path) validation_sound.reverse() return validation_sound.values ``` ```python # Arrange def get_number_of_test_files(): number_of_test_files, _ = get_test_files() return number_of_test_files ``` ```python # Arrange def generate_numpy_arrays(execution_number): number_of_test_files, test_files = get_test_files() filename = test_files[execution_number] node = prepare_node(filename) # Run the node results = node.process() print(results) # Validate the results validation_sound = get_reversed_test_sound(filename) test_sound = results['voice'].values return test_sound, validation_sound # Act @pytest.mark.parametrize('execution_number', range(len(os.listdir(AUDIO_DIR)) - 1)) def test_ReverseSoundsNode(execution_number): test_sound, validation_sound = generate_numpy_arrays(execution_number) assert np.array_equal(test_sound, validation_sound) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.