App v0.1.0
Browse files- app,py +9 -0
- app_test.ipynb +46 -2
- cq2m_utils.py +4 -2
app,py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import cq2m_utils
|
3 |
+
cq2m_interface = gr.Interface(fn=cq2m_utils.cq2m,
|
4 |
+
inputs=gr.Audio(type='filepath', format='wav'),
|
5 |
+
outputs=gr.File(type='file'),
|
6 |
+
title="Choral Quartets to Midi",
|
7 |
+
description="An application that uses Multi-Pitch Estimation and Voice Assignment to transform .WAV files with Choral Quartets recordings into MIDI files, with a separate track for each voice.")
|
8 |
+
|
9 |
+
cq2m_interface.launch()
|
app_test.ipynb
CHANGED
@@ -7,8 +7,52 @@
|
|
7 |
"outputs": [],
|
8 |
"source": [
|
9 |
"import gradio as gr\n",
|
10 |
-
"import cq2m_utils
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
]
|
13 |
}
|
14 |
],
|
|
|
7 |
"outputs": [],
|
8 |
"source": [
|
9 |
"import gradio as gr\n",
|
10 |
+
"import cq2m_utils"
|
11 |
+
]
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"cell_type": "code",
|
15 |
+
"execution_count": 2,
|
16 |
+
"metadata": {},
|
17 |
+
"outputs": [
|
18 |
+
{
|
19 |
+
"name": "stdout",
|
20 |
+
"output_type": "stream",
|
21 |
+
"text": [
|
22 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
23 |
+
"\n",
|
24 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"data": {
|
29 |
+
"text/html": [
|
30 |
+
"<div><iframe src=\"http://127.0.0.1:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
31 |
+
],
|
32 |
+
"text/plain": [
|
33 |
+
"<IPython.core.display.HTML object>"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
"metadata": {},
|
37 |
+
"output_type": "display_data"
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"data": {
|
41 |
+
"text/plain": []
|
42 |
+
},
|
43 |
+
"execution_count": 2,
|
44 |
+
"metadata": {},
|
45 |
+
"output_type": "execute_result"
|
46 |
+
}
|
47 |
+
],
|
48 |
+
"source": [
|
49 |
+
"cq2m_interface = gr.Interface(fn=cq2m_utils.cq2m,\n",
|
50 |
+
" inputs=gr.Audio(type='filepath', format='wav'),\n",
|
51 |
+
" outputs=gr.File(type='file'),\n",
|
52 |
+
" title=\"Choral Quartets to Midi\",\n",
|
53 |
+
" description=\"An application that uses Multi-Pitch Estimation and Voice Assignment to transform .WAV files with Choral Quartets recordings into MIDI files, with a separate track for each voice.\")\n",
|
54 |
+
"\n",
|
55 |
+
"cq2m_interface.launch()"
|
56 |
]
|
57 |
}
|
58 |
],
|
cq2m_utils.py
CHANGED
@@ -113,6 +113,8 @@ def create_midi(pr, write_path='./midi_track.mid', ticks_per_beat=58,
|
|
113 |
|
114 |
def song_to_midi(sop, alto, ten, bass):
|
115 |
|
|
|
|
|
116 |
down_sop = downsample_bins(sop.T)
|
117 |
down_alto = downsample_bins(alto.T)
|
118 |
down_ten = downsample_bins(ten.T)
|
@@ -126,9 +128,9 @@ def song_to_midi(sop, alto, ten, bass):
|
|
126 |
mid_mix = mido.MidiFile()
|
127 |
mid_mix.ticks_per_beat = mid_sop.ticks_per_beat
|
128 |
mid_mix.tracks = mid_sop.tracks + mid_alto.tracks + mid_ten.tracks + mid_bass.tracks
|
129 |
-
mid_mix.save(
|
130 |
|
131 |
-
return
|
132 |
|
133 |
############################################################
|
134 |
|
|
|
113 |
|
114 |
def song_to_midi(sop, alto, ten, bass):
|
115 |
|
116 |
+
savepath = './output.mid'
|
117 |
+
|
118 |
down_sop = downsample_bins(sop.T)
|
119 |
down_alto = downsample_bins(alto.T)
|
120 |
down_ten = downsample_bins(ten.T)
|
|
|
128 |
mid_mix = mido.MidiFile()
|
129 |
mid_mix.ticks_per_beat = mid_sop.ticks_per_beat
|
130 |
mid_mix.tracks = mid_sop.tracks + mid_alto.tracks + mid_ten.tracks + mid_bass.tracks
|
131 |
+
mid_mix.save(savepath)
|
132 |
|
133 |
+
return savepath
|
134 |
|
135 |
############################################################
|
136 |
|