As a self-learning project, I am designed an app where I can analyse the contents of short audio files using a spectrogram and a media player. The files are loaded with librosa and have different formats (mainly .mp3, .wav, .ogg). For each file, I only extract 10 seconds of audio which I then transform to bytes and write as a WAV file/object, as shown here. This is done from an external pre-processing function. When I try to use to use this WAV file in PyQt6 with the QMediaPlayer.setSourceDevice(), my app crashes without any informative error message. I have also looked at this post to figure out what went wrong, but I can't get this to work. Here is what the code looks like: def load_spectro(self, item): ... formatting file path with item ... spectro, audio = prepare_audiofile(this_file) ... some spectrogram display functions ... # Prepare the audio clip buf = QBuffer() buf.setData(audio.getvalue()) buf.open(QIODevice.OpenModeFlag.ReadOnly) audioOutput = QAudioOutput() self.player.setAudioOutput(audioOutput) self.player.setSourceDevice(buf) -> crashes here I am developing with VSCode 1.96.4 on Windows 11 and PyQt6==6.8.0. Before somebody suggests using this_file as a QUrl object in setSourceDevice(), one must know/remember that the .ogg format is not officially supported in Windows Media Player; that's the main reason why I have to go through the buffer way. Continue reading...