Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
improvisation_lab/presentation/interval_practice/web_interval_view.py
CHANGED
|
@@ -57,7 +57,6 @@ class WebIntervalPracticeView(WebPracticeView):
|
|
| 57 |
Returns:
|
| 58 |
gr.Blocks: The Gradio interface.
|
| 59 |
"""
|
| 60 |
-
# with gr.Blocks() as app:
|
| 61 |
with gr.Blocks(
|
| 62 |
head="""
|
| 63 |
<script src="https://cdn.jsdelivr.net/npm/tone@14.8.39/build/Tone.js">
|
|
|
|
| 57 |
Returns:
|
| 58 |
gr.Blocks: The Gradio interface.
|
| 59 |
"""
|
|
|
|
| 60 |
with gr.Blocks(
|
| 61 |
head="""
|
| 62 |
<script src="https://cdn.jsdelivr.net/npm/tone@14.8.39/build/Tone.js">
|
main.py
CHANGED
|
@@ -6,10 +6,26 @@ using either a web or console interface.
|
|
| 6 |
|
| 7 |
import argparse
|
| 8 |
|
|
|
|
|
|
|
| 9 |
from improvisation_lab.application import PracticeAppFactory
|
| 10 |
from improvisation_lab.config import Config
|
| 11 |
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def main():
|
| 14 |
"""Run the application."""
|
| 15 |
parser = argparse.ArgumentParser(description="Run the melody practice application")
|
|
@@ -27,9 +43,23 @@ def main():
|
|
| 27 |
)
|
| 28 |
args = parser.parse_args()
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
|
|
|
| 6 |
|
| 7 |
import argparse
|
| 8 |
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
from improvisation_lab.application import PracticeAppFactory
|
| 12 |
from improvisation_lab.config import Config
|
| 13 |
|
| 14 |
|
| 15 |
+
def create_practice_interface(practice_type: str) -> gr.Blocks:
|
| 16 |
+
"""Create a practice interface for the given practice type.
|
| 17 |
+
|
| 18 |
+
Args:
|
| 19 |
+
practice_type: The type of practice to create an interface for.
|
| 20 |
+
|
| 21 |
+
Returns:
|
| 22 |
+
gr.Blocks: The practice interface.
|
| 23 |
+
"""
|
| 24 |
+
config = Config()
|
| 25 |
+
app = PracticeAppFactory.create_app("web", practice_type, config)
|
| 26 |
+
return app.ui._build_interface()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
def main():
|
| 30 |
"""Run the application."""
|
| 31 |
parser = argparse.ArgumentParser(description="Run the melody practice application")
|
|
|
|
| 43 |
)
|
| 44 |
args = parser.parse_args()
|
| 45 |
|
| 46 |
+
if args.app_type == "web":
|
| 47 |
+
with gr.Blocks(
|
| 48 |
+
head="""
|
| 49 |
+
<script src="https://cdn.jsdelivr.net/npm/tone@14.8.39/build/Tone.js">
|
| 50 |
+
</script>
|
| 51 |
+
"""
|
| 52 |
+
) as app:
|
| 53 |
+
with gr.Tabs():
|
| 54 |
+
with gr.TabItem("Interval Practice"):
|
| 55 |
+
create_practice_interface("interval")
|
| 56 |
+
with gr.TabItem("Piece Practice"):
|
| 57 |
+
create_practice_interface("piece")
|
| 58 |
+
app.launch()
|
| 59 |
+
else:
|
| 60 |
+
config = Config()
|
| 61 |
+
app = PracticeAppFactory.create_app(args.app_type, args.practice_type, config)
|
| 62 |
+
app.launch()
|
| 63 |
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|