The answer to this question provides some useful code for recording an audio file in a Python program.
However, this does not seem to work in a Jupyter Notebook. It would seem that in this case the audio input of the server machine is used and not the audio input of the web browser.
Is there a way to record audio in a Jupyter Notebook?