audio2midi 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: audio2midi
3
+ Version: 0.1.0
4
+ Summary: Audio To Midi
5
+ Author-email: dummyjenil <dummyjenil@gmail.com>
6
+ Provides-Extra: all
7
+ Requires-Dist: essentia; extra == 'all'
8
+ Requires-Dist: hmmlearn; extra == 'all'
9
+ Requires-Dist: keras; extra == 'all'
10
+ Requires-Dist: librosa; extra == 'all'
11
+ Requires-Dist: mir-eval; extra == 'all'
12
+ Requires-Dist: nnaudio; extra == 'all'
13
+ Requires-Dist: numpy==1.26.4; extra == 'all'
14
+ Requires-Dist: pretty-midi; extra == 'all'
15
+ Requires-Dist: pretty-midi-fix; extra == 'all'
16
+ Requires-Dist: resampy; extra == 'all'
17
+ Requires-Dist: scipy; extra == 'all'
18
+ Requires-Dist: tensorflow; extra == 'all'
19
+ Requires-Dist: torch; extra == 'all'
20
+ Requires-Dist: torchaudio; extra == 'all'
21
+ Requires-Dist: transformers; extra == 'all'
22
+ Requires-Dist: vamp; extra == 'all'
23
+ Provides-Extra: basic-pitch-pitch-detector
24
+ Requires-Dist: librosa; extra == 'basic-pitch-pitch-detector'
25
+ Requires-Dist: nnaudio; extra == 'basic-pitch-pitch-detector'
26
+ Requires-Dist: numpy; extra == 'basic-pitch-pitch-detector'
27
+ Requires-Dist: pretty-midi-fix; extra == 'basic-pitch-pitch-detector'
28
+ Requires-Dist: scipy; extra == 'basic-pitch-pitch-detector'
29
+ Requires-Dist: torch; extra == 'basic-pitch-pitch-detector'
30
+ Provides-Extra: crepe-pitch-detector
31
+ Requires-Dist: hmmlearn; extra == 'crepe-pitch-detector'
32
+ Requires-Dist: keras; extra == 'crepe-pitch-detector'
33
+ Requires-Dist: librosa; extra == 'crepe-pitch-detector'
34
+ Requires-Dist: numpy; extra == 'crepe-pitch-detector'
35
+ Requires-Dist: pretty-midi-fix; extra == 'crepe-pitch-detector'
36
+ Requires-Dist: tensorflow; extra == 'crepe-pitch-detector'
37
+ Provides-Extra: librosa-pitch-detector
38
+ Requires-Dist: librosa; extra == 'librosa-pitch-detector'
39
+ Requires-Dist: numpy; extra == 'librosa-pitch-detector'
40
+ Requires-Dist: pretty-midi-fix; extra == 'librosa-pitch-detector'
41
+ Provides-Extra: melodia-pitch-detector
42
+ Requires-Dist: librosa; extra == 'melodia-pitch-detector'
43
+ Requires-Dist: numpy; extra == 'melodia-pitch-detector'
44
+ Requires-Dist: pretty-midi-fix; extra == 'melodia-pitch-detector'
45
+ Requires-Dist: scipy; extra == 'melodia-pitch-detector'
46
+ Requires-Dist: vamp; extra == 'melodia-pitch-detector'
47
+ Provides-Extra: pop2piano
48
+ Requires-Dist: essentia; extra == 'pop2piano'
49
+ Requires-Dist: librosa; extra == 'pop2piano'
50
+ Requires-Dist: numpy==1.26.4; extra == 'pop2piano'
51
+ Requires-Dist: pretty-midi; extra == 'pop2piano'
52
+ Requires-Dist: pretty-midi-fix; extra == 'pop2piano'
53
+ Requires-Dist: resampy; extra == 'pop2piano'
54
+ Requires-Dist: scipy; extra == 'pop2piano'
55
+ Requires-Dist: torch; extra == 'pop2piano'
56
+ Requires-Dist: transformers; extra == 'pop2piano'
57
+ Provides-Extra: violin-pitch-detector
58
+ Requires-Dist: librosa; extra == 'violin-pitch-detector'
59
+ Requires-Dist: mir-eval; extra == 'violin-pitch-detector'
60
+ Requires-Dist: numpy; extra == 'violin-pitch-detector'
61
+ Requires-Dist: pretty-midi-fix; extra == 'violin-pitch-detector'
62
+ Requires-Dist: scipy; extra == 'violin-pitch-detector'
63
+ Requires-Dist: torch; extra == 'violin-pitch-detector'
64
+ Requires-Dist: torchaudio; extra == 'violin-pitch-detector'
65
+ Description-Content-Type: text/markdown
66
+
67
+ ``` python
68
+ from audio2midi.librosa_pitch_detector import Normal_Pitch_Det , Guitar_Pitch_Det
69
+
70
+ audio_path = "audio.mp3"
71
+ Normal_Pitch_Det().predict(audio_path)
72
+ Guitar_Pitch_Det().predict(audio_path)
73
+ ```
74
+ ---
75
+ ``` python
76
+ from os import environ
77
+ from huggingface_hub import hf_hub_download
78
+ from shutil import unpack_archive
79
+ from pathlib import Path
80
+ from audio2midi.melodia_pitch_detector import Melodia
81
+ from platform import system as platform_system , architecture as platform_architecture
82
+
83
+ unpack_archive(hf_hub_download("shethjenil/Audio2Midi_Models",f"melodia_vamp_plugin_{'win' if (system := platform_system()) == 'Windows' else 'mac' if system == 'Darwin' else 'linux64' if (arch := platform_architecture()[0]) == '64bit' else 'linux32' if arch == '32bit' else None}.zip"),"vamp_melodia",format="zip")
84
+ environ['VAMP_PATH'] = str(Path("vamp_melodia").absolute())
85
+ Melodia().predict(audio_path)
86
+ ```
87
+ ---
88
+ ```python
89
+ from audio2midi.basic_pitch_pitch_detector import BasicPitch
90
+ from audio2midi.crepe_pitch_detector import Crepe
91
+ from audio2midi.violin_pitch_detector import Violin_Pitch_Det
92
+ from audio2midi.pop2piano import Pop2Piano
93
+ from torch import device as Device
94
+ from torch.cuda import is_available as cuda_is_available
95
+ device = Device("cuda" if cuda_is_available() else "cpu")
96
+ Crepe().predict(audio_path)
97
+ Pop2Piano(device=device).predict(audio_path)
98
+ Violin_Pitch_Det(device=device).predict(audio_path)
99
+ BasicPitch(device=device).predict(audio_path)
100
+ ```
@@ -0,0 +1,34 @@
1
+ ``` python
2
+ from audio2midi.librosa_pitch_detector import Normal_Pitch_Det , Guitar_Pitch_Det
3
+
4
+ audio_path = "audio.mp3"
5
+ Normal_Pitch_Det().predict(audio_path)
6
+ Guitar_Pitch_Det().predict(audio_path)
7
+ ```
8
+ ---
9
+ ``` python
10
+ from os import environ
11
+ from huggingface_hub import hf_hub_download
12
+ from shutil import unpack_archive
13
+ from pathlib import Path
14
+ from audio2midi.melodia_pitch_detector import Melodia
15
+ from platform import system as platform_system , architecture as platform_architecture
16
+
17
+ unpack_archive(hf_hub_download("shethjenil/Audio2Midi_Models",f"melodia_vamp_plugin_{'win' if (system := platform_system()) == 'Windows' else 'mac' if system == 'Darwin' else 'linux64' if (arch := platform_architecture()[0]) == '64bit' else 'linux32' if arch == '32bit' else None}.zip"),"vamp_melodia",format="zip")
18
+ environ['VAMP_PATH'] = str(Path("vamp_melodia").absolute())
19
+ Melodia().predict(audio_path)
20
+ ```
21
+ ---
22
+ ```python
23
+ from audio2midi.basic_pitch_pitch_detector import BasicPitch
24
+ from audio2midi.crepe_pitch_detector import Crepe
25
+ from audio2midi.violin_pitch_detector import Violin_Pitch_Det
26
+ from audio2midi.pop2piano import Pop2Piano
27
+ from torch import device as Device
28
+ from torch.cuda import is_available as cuda_is_available
29
+ device = Device("cuda" if cuda_is_available() else "cpu")
30
+ Crepe().predict(audio_path)
31
+ Pop2Piano(device=device).predict(audio_path)
32
+ Violin_Pitch_Det(device=device).predict(audio_path)
33
+ BasicPitch(device=device).predict(audio_path)
34
+ ```
@@ -0,0 +1,62 @@
1
+ from audio2midi.basic_pitch_pitch_detector import BasicPitch
2
+ from audio2midi.crepe_pitch_detector import Crepe
3
+ from audio2midi.librosa_pitch_detector import Normal_Pitch_Det , Guitar_Pitch_Det
4
+ from audio2midi.melodia_pitch_detector import Melodia
5
+ from audio2midi.pop2piano import Pop2Piano
6
+ from audio2midi.violin_pitch_detector import Violin_Pitch_Det
7
+
8
+ from os import environ
9
+ from huggingface_hub import hf_hub_download
10
+ from shutil import unpack_archive
11
+ from pathlib import Path
12
+ from platform import system as platform_system , architecture as platform_architecture
13
+ unpack_archive(hf_hub_download("shethjenil/Audio2Midi_Models",f"melodia_vamp_plugin_{'win' if (system := platform_system()) == 'Windows' else 'mac' if system == 'Darwin' else 'linux64' if (arch := platform_architecture()[0]) == '64bit' else 'linux32' if arch == '32bit' else None}.zip"),"vamp_melodia",format="zip")
14
+ environ['VAMP_PATH'] = str(Path("vamp_melodia").absolute())
15
+
16
+ from os import getenv
17
+ from torch import device as Device
18
+ from torch.cuda import is_available as cuda_is_available
19
+ device = Device("cuda" if cuda_is_available() else "cpu")
20
+
21
+ import gradio as gr
22
+ with gr.Blocks() as midi_viz_ui:
23
+ midi = gr.File(label="Upload MIDI")
24
+ sf = gr.File(label="Upload SoundFont")
25
+ output_html = gr.HTML(f'''
26
+ <div style="display: flex; justify-content: center; align-items: center;">
27
+ <iframe style="width: 100%; height: 500px;" src="https://shethjenil-midivizsf2.static.hf.space/index_single_file.html" id="midiviz"></iframe>
28
+ </div>''')
29
+ midi.upload(None, inputs=midi, js="""
30
+ async (file) => {
31
+ if (!file || !file.url || !file.orig_name) return;
32
+ const iframe = document.getElementById("midiviz");
33
+ iframe.contentWindow.postMessage({
34
+ type: "load-midi",
35
+ url: file.url,
36
+ name: file.orig_name
37
+ }, "*");
38
+ }
39
+ """)
40
+ sf.upload(None, inputs=sf, js="""
41
+ async (file) => {
42
+ if (!file || !file.url || !file.orig_name) return;
43
+ const iframe = document.getElementById("midiviz");
44
+ iframe.contentWindow.postMessage({
45
+ type: "load-sf",
46
+ url: file.url,
47
+ name: file.orig_name
48
+ }, "*");
49
+ }
50
+ """)
51
+
52
+ gr.TabbedInterface([
53
+ gr.Interface(Normal_Pitch_Det().predict,[gr.Audio(type="filepath",label="Input Audio"),gr.Number(120,label="BPM"),gr.Number(512,label="HOP Len"),gr.Number(512,label="minimum note length"),gr.Number(0.1,label="threshold")],gr.File(label="Midi File")),
54
+ gr.Interface(Guitar_Pitch_Det().predict,[gr.Audio(type="filepath",label="Input Audio"),gr.Number(4,label="mag_exp"),gr.Number(-61,label="Threshold"),gr.Number(6,label="Pre_post_max"),gr.Checkbox(False,label="backtrack"),gr.Checkbox(False,label="round_to_sixteenth"),gr.Number(1024,label="hop_length"),gr.Number(72,label="n_bins"),gr.Number(12,label="bins_per_octave")],gr.File(label="Midi File")),
55
+ gr.Interface(Melodia().predict,[gr.Audio(type="filepath",label="Input Audio"),gr.Number(120,label="BPM",step=30),gr.Number(0.25,label="smoothness",step=0.05,info="Smooth the pitch sequence with a median filter of the provided duration (in seconds)."),gr.Number(0.1,label="minimum duration",step=0.1,info="Minimum allowed duration for note (in seconds). Shorter notes will be removed."),gr.Number(128,label="HOP")],gr.File(label="Midi File")),
56
+ gr.Interface(BasicPitch(device=device).predict,[gr.Audio(type="filepath", label="Upload Audio"),gr.Number(0.5,label="onset_thresh",info="Minimum amplitude of an onset activation to be considered an onset."),gr.Number(0.3,label="frame_thresh",info="Minimum energy requirement for a frame to be considered present."),gr.Number(127.70,label="min_note_len",info="The minimum allowed note length in milliseconds."),gr.Number(120,label="midi_tempo"),gr.Checkbox(True,label="infer_onsets",info="add additional onsets when there are large differences in frame amplitudes."),gr.Checkbox(True,label="include_pitch_bends",info="include pitch bends."),gr.Checkbox(False,label="multiple_pitch_bends",info="allow overlapping notes in midi file to have pitch bends."),gr.Checkbox(True,label="melodia_trick",info="Use the melodia post-processing step.")],gr.File(label="Download Midi File")),
57
+ gr.Interface(Violin_Pitch_Det(device=device,model_capacity=getenv("violin_model_capacity","full")).predict, [gr.Audio(label="Upload your Audio file",type="filepath"),gr.Number(32,label="Batch size"),gr.Radio(["spotify","tiktok"],value="spotify",label="Post Processing"),gr.Checkbox(True,label="include_pitch_bends")],gr.File(label="Download MIDI file")),
58
+ gr.Interface(Crepe(getenv("crepe_model_capacity","full")).predict,[gr.Audio(type="filepath",label="Input Audio"),gr.Checkbox(False,label="viterbi",info="Apply viterbi smoothing to the estimated pitch curve"),gr.Checkbox(True,label="center"),gr.Number(10,label="step size",info="The step size in milliseconds for running pitch estimation."),gr.Number(0.8,label="minimum confidence"),gr.Number(32,label="batch size")],gr.File(label="Midi File")),
59
+ gr.Interface(Pop2Piano(device).predict,[gr.Audio(label="Input Audio",type="filepath"),gr.Number(1, minimum=1, maximum=21, label="Composer"),gr.Number(2,label="Details in Piano"),gr.Number(1,label="Efficiency of Piano"),gr.Radio([1,2,4],label="steps per beat",value=2)],gr.File(label="MIDI File")),
60
+ midi_viz_ui
61
+ ],["Normal Pitch Detection","Guitar Based Pitch Detection","Melodia","Spotify Pitch Detection","Violin Based Pitch Detection","Crepe Pitch Detection","Pop2Piano","Midi Vizulizer"]).launch()
62
+
@@ -0,0 +1,23 @@
1
+ [project]
2
+ name = "audio2midi"
3
+ version = "0.1.0"
4
+ description = "Audio To Midi"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "dummyjenil", email = "dummyjenil@gmail.com" }
8
+ ]
9
+
10
+ dependencies = []
11
+
12
+ [project.optional-dependencies]
13
+ librosa_pitch_detector = ["librosa", "numpy","pretty_midi_fix"]
14
+ basic_pitch_pitch_detector = ["librosa", "numpy","pretty_midi_fix","scipy","torch","nnAudio"]
15
+ melodia_pitch_detector = ["librosa", "numpy","pretty_midi_fix","scipy","vamp"]
16
+ crepe_pitch_detector = ["librosa", "numpy","pretty_midi_fix","hmmlearn","tensorflow","keras"]
17
+ violin_pitch_detector = ["librosa", "numpy","pretty_midi_fix","scipy","torchaudio","torch","mir_eval"]
18
+ pop2piano = ["librosa", "numpy==1.26.4","pretty_midi_fix","transformers","essentia","torch","scipy","resampy","pretty_midi"]
19
+ all = ["librosa", "numpy==1.26.4","pretty_midi_fix","transformers","essentia","torch","scipy","torchaudio","torch","mir_eval","hmmlearn","tensorflow","keras","vamp","nnAudio","resampy","pretty_midi"]
20
+
21
+ [build-system]
22
+ requires = ["hatchling"]
23
+ build-backend = "hatchling.build"
File without changes