Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- improvisation_lab/config.py +3 -3
- improvisation_lab/infrastructure/audio/audio_processor.py +1 -1
- improvisation_lab/infrastructure/audio/web_processor.py +1 -1
- improvisation_lab/presentation/interval_practice/web_interval_view.py +1 -1
- tests/service/test_base_practice_service.py +4 -4
- tests/test_config.py +2 -2
improvisation_lab/config.py
CHANGED
@@ -10,7 +10,7 @@ import yaml
|
|
10 |
class PitchDetectorConfig:
|
11 |
"""Configuration settings for pitch detection."""
|
12 |
|
13 |
-
sample_rate: int =
|
14 |
hop_length: int = 512
|
15 |
decoder_mode: str = "local_argmax"
|
16 |
threshold: float = 0.006
|
@@ -24,8 +24,8 @@ class PitchDetectorConfig:
|
|
24 |
class AudioConfig:
|
25 |
"""Configuration class for audio-related settings."""
|
26 |
|
27 |
-
sample_rate: int =
|
28 |
-
buffer_duration: float = 0.
|
29 |
note_duration: float = 1.0
|
30 |
pitch_detector: PitchDetectorConfig = field(default_factory=PitchDetectorConfig)
|
31 |
|
|
|
10 |
class PitchDetectorConfig:
|
11 |
"""Configuration settings for pitch detection."""
|
12 |
|
13 |
+
sample_rate: int = 16000
|
14 |
hop_length: int = 512
|
15 |
decoder_mode: str = "local_argmax"
|
16 |
threshold: float = 0.006
|
|
|
24 |
class AudioConfig:
|
25 |
"""Configuration class for audio-related settings."""
|
26 |
|
27 |
+
sample_rate: int = 16000
|
28 |
+
buffer_duration: float = 0.3
|
29 |
note_duration: float = 1.0
|
30 |
pitch_detector: PitchDetectorConfig = field(default_factory=PitchDetectorConfig)
|
31 |
|
improvisation_lab/infrastructure/audio/audio_processor.py
CHANGED
@@ -13,7 +13,7 @@ class AudioProcessor(ABC):
|
|
13 |
self,
|
14 |
sample_rate: int,
|
15 |
callback: Callable[[np.ndarray], None] | None = None,
|
16 |
-
buffer_duration: float = 0.
|
17 |
):
|
18 |
"""Initialize AudioInput.
|
19 |
|
|
|
13 |
self,
|
14 |
sample_rate: int,
|
15 |
callback: Callable[[np.ndarray], None] | None = None,
|
16 |
+
buffer_duration: float = 0.3,
|
17 |
):
|
18 |
"""Initialize AudioInput.
|
19 |
|
improvisation_lab/infrastructure/audio/web_processor.py
CHANGED
@@ -16,7 +16,7 @@ class WebAudioProcessor(AudioProcessor):
|
|
16 |
self,
|
17 |
sample_rate: int,
|
18 |
callback: Callable[[np.ndarray], None] | None = None,
|
19 |
-
buffer_duration: float = 0.
|
20 |
):
|
21 |
"""Initialize GradioAudioInput.
|
22 |
|
|
|
16 |
self,
|
17 |
sample_rate: int,
|
18 |
callback: Callable[[np.ndarray], None] | None = None,
|
19 |
+
buffer_duration: float = 0.3,
|
20 |
):
|
21 |
"""Initialize GradioAudioInput.
|
22 |
|
improvisation_lab/presentation/interval_practice/web_interval_view.py
CHANGED
@@ -207,5 +207,5 @@ class WebIntervalPracticeView(WebPracticeView):
|
|
207 |
self.results_table,
|
208 |
],
|
209 |
show_progress=False,
|
210 |
-
stream_every=0.
|
211 |
)
|
|
|
207 |
self.results_table,
|
208 |
],
|
209 |
show_progress=False,
|
210 |
+
stream_every=0.3,
|
211 |
)
|
tests/service/test_base_practice_service.py
CHANGED
@@ -36,7 +36,7 @@ class TestBasePracticeService:
|
|
36 |
@pytest.mark.usefixtures("init_module")
|
37 |
def test_process_audio_with_voice(self):
|
38 |
"""Test processing audio with voice detected."""
|
39 |
-
sample_rate =
|
40 |
duration = 0.1
|
41 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
42 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
@@ -50,7 +50,7 @@ class TestBasePracticeService:
|
|
50 |
@pytest.mark.usefixtures("init_module")
|
51 |
def test_process_audio_incorrect_pitch(self):
|
52 |
"""Test processing audio with incorrect pitch."""
|
53 |
-
sample_rate =
|
54 |
duration = 0.1
|
55 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
56 |
# Generate 440Hz (A4) when target is C4
|
@@ -66,7 +66,7 @@ class TestBasePracticeService:
|
|
66 |
@pytest.mark.usefixtures("init_module")
|
67 |
def test_correct_pitch_timing(self):
|
68 |
"""Test timing behavior with correct pitch."""
|
69 |
-
sample_rate =
|
70 |
duration = 0.1
|
71 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
72 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
@@ -89,7 +89,7 @@ class TestBasePracticeService:
|
|
89 |
@pytest.mark.usefixtures("init_module")
|
90 |
def test_correct_pitch_completion(self):
|
91 |
"""Test completion of correct pitch duration."""
|
92 |
-
sample_rate =
|
93 |
duration = 0.1
|
94 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
95 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
|
|
36 |
@pytest.mark.usefixtures("init_module")
|
37 |
def test_process_audio_with_voice(self):
|
38 |
"""Test processing audio with voice detected."""
|
39 |
+
sample_rate = 16000
|
40 |
duration = 0.1
|
41 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
42 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
|
|
50 |
@pytest.mark.usefixtures("init_module")
|
51 |
def test_process_audio_incorrect_pitch(self):
|
52 |
"""Test processing audio with incorrect pitch."""
|
53 |
+
sample_rate = 16000
|
54 |
duration = 0.1
|
55 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
56 |
# Generate 440Hz (A4) when target is C4
|
|
|
66 |
@pytest.mark.usefixtures("init_module")
|
67 |
def test_correct_pitch_timing(self):
|
68 |
"""Test timing behavior with correct pitch."""
|
69 |
+
sample_rate = 16000
|
70 |
duration = 0.1
|
71 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
72 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
|
|
89 |
@pytest.mark.usefixtures("init_module")
|
90 |
def test_correct_pitch_completion(self):
|
91 |
"""Test completion of correct pitch duration."""
|
92 |
+
sample_rate = 16000
|
93 |
duration = 0.1
|
94 |
t = np.linspace(0, duration, int(sample_rate * duration))
|
95 |
audio_data = np.sin(2 * np.pi * 440 * t)
|
tests/test_config.py
CHANGED
@@ -50,8 +50,8 @@ class TestConfig:
|
|
50 |
"""Test loading configuration with default values when file doesn't exist."""
|
51 |
config = Config(config_path="nonexistent.yml")
|
52 |
|
53 |
-
assert config.audio.sample_rate ==
|
54 |
-
assert config.audio.buffer_duration == 0.
|
55 |
assert config.audio.note_duration == 1.0
|
56 |
assert config.interval_practice.num_problems == 10
|
57 |
assert config.interval_practice.interval == 1
|
|
|
50 |
"""Test loading configuration with default values when file doesn't exist."""
|
51 |
config = Config(config_path="nonexistent.yml")
|
52 |
|
53 |
+
assert config.audio.sample_rate == 16000
|
54 |
+
assert config.audio.buffer_duration == 0.3
|
55 |
assert config.audio.note_duration == 1.0
|
56 |
assert config.interval_practice.num_problems == 10
|
57 |
assert config.interval_practice.interval == 1
|