audio2midi 0.2.0__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: audio2midi
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Audio To Midi
5
5
  Author-email: dummyjenil <dummyjenil@gmail.com>
6
6
  Provides-Extra: all
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "audio2midi"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Audio To Midi"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -17,11 +17,14 @@ class PredictProgressCallback(Callback):
17
17
  self.total_batches = total_batches
18
18
  self.progress_callback = progress_callback
19
19
  def on_predict_begin(self, logs=None):
20
- self.progress_callback(0,self.total_batches)
20
+ if self.progress_callback:
21
+ self.progress_callback(0,self.total_batches)
21
22
  def on_predict_batch_end(self, batch, logs=None):
22
- self.progress_callback(batch,self.total_batches)
23
+ if self.progress_callback:
24
+ self.progress_callback(batch,self.total_batches)
23
25
  def on_predict_end(self, logs=None):
24
- self.progress_callback(self.total_batches,self.total_batches)
26
+ if self.progress_callback:
27
+ self.progress_callback(self.total_batches,self.total_batches)
25
28
 
26
29
 
27
30
  class Crepe():
@@ -1,4 +1,3 @@
1
- from typing import Callable
2
1
  import librosa
3
2
  from pretty_midi_fix import Instrument , PrettyMIDI , Note
4
3
  import numpy as np
@@ -1270,7 +1270,8 @@ class Violin_Pitch_Det(Pitch_Det):
1270
1270
  value = value.view(-1, value.shape[-1])
1271
1271
  value = value.detach().cpu().numpy()
1272
1272
  performance[key].append(value)
1273
- progress_callback(i,len(frames))
1273
+ if progress_callback:
1274
+ progress_callback(i,len(frames))
1274
1275
  performance = {key: np.concatenate(value, axis=0)[:len(times)] for key, value in performance.items()}
1275
1276
  performance['time'] = times
1276
1277
  return performance
audio2midi-0.2.0/app.py DELETED
@@ -1,62 +0,0 @@
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
-
File without changes
File without changes
File without changes