Skip to content

Commit 519de7f

Browse files
committed
Minor code cleanup
1 parent 07918fd commit 519de7f

File tree

4 files changed

+4
-49
lines changed

4 files changed

+4
-49
lines changed

audio_separator/separator/uvr_lib_v5/demucs/apply.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from concurrent.futures import ThreadPoolExecutor
1111
import random
1212
import typing as tp
13-
from multiprocessing import Process, Queue, Pipe
1413

1514
import torch as th
1615
from torch import nn

audio_separator/separator/uvr_lib_v5/playsound.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def _playsoundWin(sound, block = True):
3131
sound = '"' + _canonicalizePath(sound) + '"'
3232

3333
from ctypes import create_unicode_buffer, windll, wintypes
34-
from time import sleep
3534
windll.winmm.mciSendStringW.argtypes = [wintypes.LPCWSTR, wintypes.LPWSTR, wintypes.UINT, wintypes.HANDLE]
3635
windll.winmm.mciGetErrorStringW.argtypes = [wintypes.DWORD, wintypes.LPWSTR, wintypes.UINT]
3736

tests/unit/test_cli.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_cli_normalization_threshold_argument(common_expected_args):
175175
mock_separator.assert_called_once_with(**expected_args)
176176

177177

178-
# Test using normalization_threshold argument
178+
# Test using amplification_threshold argument
179179
def test_cli_amplification_threshold_argument(common_expected_args):
180180
test_args = ["cli.py", "test_audio.mp3", "--amplification=0.75"]
181181
with patch("sys.argv", test_args):
@@ -243,36 +243,6 @@ def test_cli_use_autocast_argument(common_expected_args):
243243
mock_separator.assert_called_once_with(**expected_args)
244244

245245

246-
# Test using custom_output_names argument
247-
def test_cli_Vocals_output_name_argument(common_expected_args):
248-
custom_vocals_names = {"Vocals": "vocals_output"}
249-
test_args = ["cli.py", "test_audio.mp3", f"--custom_output_names={json.dumps(custom_vocals_names)}"]
250-
with patch("sys.argv", test_args):
251-
with patch("audio_separator.separator.Separator") as mock_separator:
252-
mock_separator_instance = mock_separator.return_value
253-
mock_separator_instance.separate.return_value = ["output_file.mp3"]
254-
main()
255-
256-
# Assertions
257-
mock_separator.assert_called_once_with(**common_expected_args)
258-
mock_separator_instance.separate.assert_called_once_with("test_audio.mp3", custom_output_names=custom_vocals_names)
259-
260-
261-
# Test using custom_output_names argument
262-
def test_cli_Instrumental_output_name_argument(common_expected_args):
263-
custom_instrumental_names = {"Instrumental": "instrumental_output"}
264-
test_args = ["cli.py", "test_audio.mp3", f"--custom_output_names={json.dumps(custom_instrumental_names)}"]
265-
with patch("sys.argv", test_args):
266-
with patch("audio_separator.separator.Separator") as mock_separator:
267-
mock_separator_instance = mock_separator.return_value
268-
mock_separator_instance.separate.return_value = ["output_file.mp3"]
269-
main()
270-
271-
# Assertions
272-
mock_separator.assert_called_once_with(**common_expected_args)
273-
mock_separator_instance.separate.assert_called_once_with("test_audio.mp3", custom_output_names=custom_instrumental_names)
274-
275-
276246
# Test using custom_output_names arguments
277247
def test_cli_custom_output_names_argument(common_expected_args):
278248
custom_names = {

tests/unit/test_stft.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import numpy as np
33
import torch
4-
from unittest.mock import Mock, patch
4+
from unittest.mock import Mock
55
from audio_separator.separator.uvr_lib_v5.stft import STFT
66

77
# Short-Time Fourier Transform (STFT) Process Overview:
@@ -121,29 +121,16 @@ def test_prepare_for_istft(self):
121121
# Assertions
122122
self.assertEqual(complex_tensor.shape, expected_shape)
123123

124-
def test_inverse_device_handling(self):
124+
def test_inverse_stft(self):
125125
# Create a mock tensor with the correct input shape
126126
input_tensor = torch.rand(1, 2, 1025, 32) # shape matching output of STFT
127127

128-
# Initialize STFT
129-
stft = STFT(logger=MockLogger(), n_fft=2048, hop_length=512, dim_f=1025, device="cpu")
130-
131128
# Apply inverse STFT
132-
output_tensor = stft.inverse(input_tensor)
129+
output_tensor = self.stft.inverse(input_tensor)
133130

134131
# Check if the output tensor is on the CPU
135132
self.assertEqual(output_tensor.device.type, "cpu")
136133

137-
def test_inverse_output_shape(self):
138-
# Create a mock tensor
139-
input_tensor = torch.rand(1, 2, 1025, 32) # shape matching output of STFT
140-
141-
# Initialize STFT
142-
stft = STFT(logger=MockLogger(), n_fft=2048, hop_length=512, dim_f=1025, device="cpu")
143-
144-
# Apply inverse STFT
145-
output_tensor = stft.inverse(input_tensor)
146-
147134
# Expected output shape: (Batch size, Channel dimension, Time dimension)
148135
expected_shape = (1, 2, 7936) # Calculated based on STFT parameters
149136

0 commit comments

Comments
 (0)