Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- improvisation_lab/application/app_factory.py +8 -8
- improvisation_lab/application/base_app.py +2 -3
- improvisation_lab/application/interval_practice/__init__.py +2 -0
- improvisation_lab/application/interval_practice/console_interval_app.py +4 -0
- improvisation_lab/presentation/interval_practice/__init__.py +6 -0
- improvisation_lab/presentation/interval_practice/web_interval_view.py +7 -1
- improvisation_lab/presentation/piece_practice/__init__.py +2 -2
- improvisation_lab/presentation/piece_practice/web_piece_view.py +1 -1
- improvisation_lab/presentation/web_view.py +1 -1
improvisation_lab/application/app_factory.py
CHANGED
@@ -23,20 +23,20 @@ class PracticeAppFactory:
|
|
23 |
"""
|
24 |
if app_type == "web":
|
25 |
if practice_type == "piece":
|
26 |
-
|
27 |
-
return WebPiecePracticeApp(
|
28 |
elif practice_type == "interval":
|
29 |
-
|
30 |
-
return WebIntervalPracticeApp(
|
31 |
else:
|
32 |
raise ValueError(f"Unknown practice type: {practice_type}")
|
33 |
elif app_type == "console":
|
34 |
if practice_type == "piece":
|
35 |
-
|
36 |
-
return ConsolePiecePracticeApp(
|
37 |
elif practice_type == "interval":
|
38 |
-
|
39 |
-
return ConsoleIntervalPracticeApp(
|
40 |
else:
|
41 |
raise ValueError(f"Unknown practice type: {practice_type}")
|
42 |
else:
|
|
|
23 |
"""
|
24 |
if app_type == "web":
|
25 |
if practice_type == "piece":
|
26 |
+
piece_service = PiecePracticeService(config)
|
27 |
+
return WebPiecePracticeApp(piece_service, config)
|
28 |
elif practice_type == "interval":
|
29 |
+
interval_service = IntervalPracticeService(config)
|
30 |
+
return WebIntervalPracticeApp(interval_service, config)
|
31 |
else:
|
32 |
raise ValueError(f"Unknown practice type: {practice_type}")
|
33 |
elif app_type == "console":
|
34 |
if practice_type == "piece":
|
35 |
+
piece_service = PiecePracticeService(config)
|
36 |
+
return ConsolePiecePracticeApp(piece_service, config)
|
37 |
elif practice_type == "interval":
|
38 |
+
interval_service = IntervalPracticeService(config)
|
39 |
+
return ConsoleIntervalPracticeApp(interval_service, config)
|
40 |
else:
|
41 |
raise ValueError(f"Unknown practice type: {practice_type}")
|
42 |
else:
|
improvisation_lab/application/base_app.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
"""Base class for melody practice applications."""
|
2 |
|
3 |
from abc import ABC, abstractmethod
|
4 |
-
from typing import
|
5 |
|
6 |
import numpy as np
|
7 |
|
8 |
from improvisation_lab.config import Config
|
9 |
-
from improvisation_lab.domain.composition import PhraseData
|
10 |
from improvisation_lab.service.base_practice_service import BasePracticeService
|
11 |
|
12 |
|
@@ -22,7 +21,7 @@ class BasePracticeApp(ABC):
|
|
22 |
"""
|
23 |
self.service = service
|
24 |
self.config = config
|
25 |
-
self.phrases: Optional[
|
26 |
self.current_phrase_idx: int = 0
|
27 |
self.current_note_idx: int = 0
|
28 |
self.is_running: bool = False
|
|
|
1 |
"""Base class for melody practice applications."""
|
2 |
|
3 |
from abc import ABC, abstractmethod
|
4 |
+
from typing import Any, Optional
|
5 |
|
6 |
import numpy as np
|
7 |
|
8 |
from improvisation_lab.config import Config
|
|
|
9 |
from improvisation_lab.service.base_practice_service import BasePracticeService
|
10 |
|
11 |
|
|
|
21 |
"""
|
22 |
self.service = service
|
23 |
self.config = config
|
24 |
+
self.phrases: Optional[Any] = None
|
25 |
self.current_phrase_idx: int = 0
|
26 |
self.current_note_idx: int = 0
|
27 |
self.is_running: bool = False
|
improvisation_lab/application/interval_practice/__init__.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from improvisation_lab.application.interval_practice.console_interval_app import \
|
2 |
ConsoleIntervalPracticeApp
|
3 |
from improvisation_lab.application.interval_practice.web_interval_app import \
|
|
|
1 |
+
"""Application layer for interval practice."""
|
2 |
+
|
3 |
from improvisation_lab.application.interval_practice.console_interval_app import \
|
4 |
ConsoleIntervalPracticeApp
|
5 |
from improvisation_lab.application.interval_practice.web_interval_app import \
|
improvisation_lab/application/interval_practice/console_interval_app.py
CHANGED
@@ -31,10 +31,14 @@ class ConsoleIntervalPracticeApp(ConsoleBasePracticeApp):
|
|
31 |
Returns:
|
32 |
The current note to be processed.
|
33 |
"""
|
|
|
|
|
34 |
return self.phrases[self.current_phrase_idx][self.current_note_idx].value
|
35 |
|
36 |
def _get_current_phrase(self) -> List[Notes]:
|
37 |
"""Return the current phrase to be processed."""
|
|
|
|
|
38 |
return self.phrases[self.current_phrase_idx]
|
39 |
|
40 |
def _generate_melody(self) -> List[List[Notes]]:
|
|
|
31 |
Returns:
|
32 |
The current note to be processed.
|
33 |
"""
|
34 |
+
if self.phrases is None:
|
35 |
+
raise ValueError("Phrases are not initialized.")
|
36 |
return self.phrases[self.current_phrase_idx][self.current_note_idx].value
|
37 |
|
38 |
def _get_current_phrase(self) -> List[Notes]:
|
39 |
"""Return the current phrase to be processed."""
|
40 |
+
if self.phrases is None:
|
41 |
+
raise ValueError("Phrases are not initialized.")
|
42 |
return self.phrases[self.current_phrase_idx]
|
43 |
|
44 |
def _generate_melody(self) -> List[List[Notes]]:
|
improvisation_lab/presentation/interval_practice/__init__.py
CHANGED
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from improvisation_lab.presentation.interval_practice.console_interval_view import \
|
2 |
ConsoleIntervalPracticeView
|
3 |
from improvisation_lab.presentation.interval_practice.interval_view_text_manager import \
|
|
|
1 |
+
"""Presentation layer for interval practice.
|
2 |
+
|
3 |
+
This package contains modules for handling the user interface
|
4 |
+
and text management for interval practice applications.
|
5 |
+
"""
|
6 |
+
|
7 |
from improvisation_lab.presentation.interval_practice.console_interval_view import \
|
8 |
ConsoleIntervalPracticeView
|
9 |
from improvisation_lab.presentation.interval_practice.interval_view_text_manager import \
|
improvisation_lab/presentation/interval_practice/web_interval_view.py
CHANGED
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from typing import Callable, Tuple
|
2 |
|
3 |
import gradio as gr
|
@@ -15,7 +21,7 @@ class WebIntervalPracticeView(WebPracticeView):
|
|
15 |
self,
|
16 |
on_generate_melody: Callable[[str, str, int], Tuple[str, str, str]],
|
17 |
on_end_practice: Callable[[], Tuple[str, str, str]],
|
18 |
-
on_audio_input: Callable[[int, np.ndarray], Tuple[str, str, str]],
|
19 |
config: Config,
|
20 |
):
|
21 |
"""Initialize the UI with callback functions.
|
|
|
1 |
+
"""Web-based interval practice view.
|
2 |
+
|
3 |
+
This module provides a web interface using Gradio for visualizing
|
4 |
+
and interacting with interval practice sessions.
|
5 |
+
"""
|
6 |
+
|
7 |
from typing import Callable, Tuple
|
8 |
|
9 |
import gradio as gr
|
|
|
21 |
self,
|
22 |
on_generate_melody: Callable[[str, str, int], Tuple[str, str, str]],
|
23 |
on_end_practice: Callable[[], Tuple[str, str, str]],
|
24 |
+
on_audio_input: Callable[[Tuple[int, np.ndarray]], Tuple[str, str, str]],
|
25 |
config: Config,
|
26 |
):
|
27 |
"""Initialize the UI with callback functions.
|
improvisation_lab/presentation/piece_practice/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
"""Presentation layer for
|
2 |
|
3 |
This package contains modules for handling the user interface
|
4 |
-
and text management for
|
5 |
"""
|
6 |
|
7 |
from improvisation_lab.presentation.piece_practice.console_piece_view import \
|
|
|
1 |
+
"""Presentation layer for piece practice.
|
2 |
|
3 |
This package contains modules for handling the user interface
|
4 |
+
and text management for piece practice applications.
|
5 |
"""
|
6 |
|
7 |
from improvisation_lab.presentation.piece_practice.console_piece_view import \
|
improvisation_lab/presentation/piece_practice/web_piece_view.py
CHANGED
@@ -19,7 +19,7 @@ class WebPiecePracticeView(WebPracticeView):
|
|
19 |
self,
|
20 |
on_generate_melody: Callable[[], Tuple[str, str]],
|
21 |
on_end_practice: Callable[[], Tuple[str, str]],
|
22 |
-
on_audio_input: Callable[[int, np.ndarray], Tuple[str, str]],
|
23 |
song_name: str,
|
24 |
):
|
25 |
"""Initialize the UI with callback functions.
|
|
|
19 |
self,
|
20 |
on_generate_melody: Callable[[], Tuple[str, str]],
|
21 |
on_end_practice: Callable[[], Tuple[str, str]],
|
22 |
+
on_audio_input: Callable[[Tuple[int, np.ndarray]], Tuple[str, str]],
|
23 |
song_name: str,
|
24 |
):
|
25 |
"""Initialize the UI with callback functions.
|
improvisation_lab/presentation/web_view.py
CHANGED
@@ -18,7 +18,7 @@ class WebPracticeView(ABC):
|
|
18 |
self,
|
19 |
on_generate_melody: Callable[..., Tuple[Any, ...]],
|
20 |
on_end_practice: Callable[[], Tuple[Any, ...]],
|
21 |
-
on_audio_input: Callable[[int, np.ndarray], Tuple[Any, ...]],
|
22 |
):
|
23 |
"""Initialize the UI with callback functions.
|
24 |
|
|
|
18 |
self,
|
19 |
on_generate_melody: Callable[..., Tuple[Any, ...]],
|
20 |
on_end_practice: Callable[[], Tuple[Any, ...]],
|
21 |
+
on_audio_input: Callable[[Tuple[int, np.ndarray]], Tuple[Any, ...]],
|
22 |
):
|
23 |
"""Initialize the UI with callback functions.
|
24 |
|