Estimate a microphone's transfer function
Your $H^{-1}$ is effectively what is called a zero-forcing equalizer for the channel represented by $H$. That channel incorporates DAC, amplifier, speaker, your room, the microphone, amplifier, ADC and several filters necessary to fulfill sampling conditions.

Problem is that for any frequency where $H$ has a notch, $H^{-1}$ has to have a very strong amplification! Sadly, that means that the frequencies where your estimate is based on the least received energy have the largest amplitude in the resulting inverted channel model. That leads to amplified noise.

There's a lot of ways to estimate a channel inverse; the MMSE estimator is pretty popular in communications.

Because you ask for a Python implementation: GNU Radio is usually used from Python, and there's multiple equalizers that come with it (try first!); and, there's modules like gr-adapt which allow for calculating (and using!) channel-reversing filters adaptively. What I especially like about gr-adapt is that its documentation and comments are plentiful and come with references.

For example, have a look at https://github.com/karel/gr-adapt/tree/master/examples :



Here, gr-adapt's LMS Filter is used to estimate (and invert) the channel (which is simulated using the Decimating FIR Filter block).