My experience/backround: pipy / python is more complex setup than using midi2tex,awk to format for grep search.
Awk typically used to convert files between formats. There are readily available midi to text conversion tool(s) finable via a search engine.
In this case, using awk to convert midi file to text format (or make use of a format from a midi to text tool) that can be use with grep would be the implied step.