Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes in MIDI output are different in python program compared to the demo website #134

Open
pulsar666 opened this issue Aug 7, 2024 · 3 comments

Comments

@pulsar666
Copy link

pulsar666 commented Aug 7, 2024

Description:
I'm experiencing an issue where the MIDI output generated by the basic_pitch library on my local machine has a lot of off notes. However, when I use the demo website, the notes seem to be correct. This appears to be similar to the issue discussed in #[126], but I'm still encountering the problem.

Environment:

  • OS: Windows 10
  • Python version: 3.11
  • Basic Pitch version: latest
  • TensorFlow version: latest

Steps to Reproduce:

  1. Install the required packages:

    pip install basic_pitch[tf]
  2. Use the following script to convert an audio file to MIDI:

    import os
    from basic_pitch.inference import predict_and_save
    from basic_pitch import ICASSP_2022_MODEL_PATH
    
    def convert_to_midi(audio_file, output_directory):
        print(audio_file)
        # Verify the file exists
        if not os.path.exists(audio_file):
            raise FileNotFoundError(f"File not found: {audio_file}")
    
        try:
            predict_and_save(
                audio_path_list=[audio_file],  # <input-audio-path-list>
                output_directory=output_directory,  # <output-directory>
                save_midi=True,  # <save-midi>
                sonify_midi=False,  # <sonify-midi>
                save_model_outputs=True,  # <save-model-outputs>
                save_notes=True,  # <save-notes>
                model_or_model_path=ICASSP_2022_MODEL_PATH,
                minimum_note_length=11,
                maximum_frequency=3000.0,  # Maximum Pitch
            )
        except Exception as e:
            print(f"Error reading or converting audio file: {e}")
            raise
    
    output_dir = 'output'
    convert_to_midi("E:/Data/pycharm_projects/azimuth-melody-extraction-v2/output_directory/test-audio.wav", output_dir)
    print(f"MIDI file is saved at {output_dir}")
  3. Compare the MIDI output generated by the script with the output generated by the demo website.

Expected behavior:
The MIDI output generated by the script should have the correct notes, similar to the output generated by the demo website.

Actual behavior:
The MIDI output generated by the script has a lot of off notes.

Additional context:

  • I have verified that the audio file used for testing is the same in both cases.
  • The model path used in the script is ICASSP_2022_MODEL_PATH.
  • This issue seems related to #[126] which is now closed, but the problem persists.

Would be great if anyone can tell me how to get the exact output that is produced by the demo website: basic pitch demo

@pulsar666
Copy link
Author

anyone that can help with correct settings for the predict_and_save() that will produce the same output as the demo site?

@pulsar666
Copy link
Author

I believe the python version is causing is. I tried with 3.10 and the notes do overlap with what is being produced by the demo site, although the pitch velocities are definitely different

@drubinstein
Copy link
Contributor

Hi and thanks for your interest in Basic Pitch.

A few follow up questions:

  • Are you ensuring that all the parameters on the website match what you are using locally
  • When you say TF latest, which version do you actually mean? Basic-Pitch installs tf<2.16, i.e. less than latest

If you have an audio file you could share that'd also be great. It looks like the velocities in basic-pitch and basic-pitch-ts could be slightly different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants