Instructions to use jmp684/CornetAI with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use jmp684/CornetAI with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy) # See https://github.com/keras-team/tf-keras for more details. from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("jmp684/CornetAI") - Notebooks
- Google Colab
- Kaggle
| import os | |
| import subprocess | |
| import pretty_midi | |
| # --- CONFIGURA ESTO --- | |
| SOUNDFONT_PATH = r"C:\Users\pampi\Documents\corneta.sf2" | |
| INPUT_FOLDER = "a" | |
| OUTPUT_FOLDER = "b" | |
| TARGET_PROGRAM = 40 # Preset de tu corneta (0-127) | |
| # ---------------------- | |
| def synthesize(): | |
| if not os.path.exists(OUTPUT_FOLDER): os.makedirs(OUTPUT_FOLDER) | |
| # Limpiar WAVs viejos si existen | |
| for f in os.listdir(OUTPUT_FOLDER): os.remove(os.path.join(OUTPUT_FOLDER, f)) | |
| files = [f for f in os.listdir(INPUT_FOLDER) if f.endswith('.mid')] | |
| print(f"Sintetizando {len(files)} archivos...") | |
| for midi_file in files: | |
| # Parchear MIDI | |
| midi_path = os.path.join(INPUT_FOLDER, midi_file) | |
| pm = pretty_midi.PrettyMIDI(midi_path) | |
| for inst in pm.instruments: | |
| inst.program = TARGET_PROGRAM | |
| temp_midi = os.path.join(INPUT_FOLDER, "temp.mid") | |
| pm.write(temp_midi) | |
| # Convertir | |
| wav_name = midi_file.replace(".mid", ".wav") | |
| wav_path = os.path.join(OUTPUT_FOLDER, wav_name) | |
| cmd = [ | |
| 'fluidsynth', '-ni', '-F', wav_path, '-r', '22050', '-g', '1.0', | |
| SOUNDFONT_PATH, temp_midi | |
| ] | |
| subprocess.run(cmd, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | |
| print(f"-> {wav_name}") | |
| if os.path.exists(temp_midi): os.remove(temp_midi) | |
| print("Paso 2: WAVs generados.") | |
| if __name__ == "__main__": | |
| synthesize() |