Created
April 17, 2024 19:33
-
-
Save pjohnst5/e069ec94518b99faa5e260d3352f5973 to your computer and use it in GitHub Desktop.
This is to reproduce a bug where audio recording (from microhpone) does not work on PyQT 6.7.0, MacOS, arm64 chip, Python 3.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When running this with PySide 6.4.2 on Mac ARM64 chip Python 3.9, recording audio works | |
# When upgrading PySide to 6.7.0 (keeping everything else constant), recording fails | |
import sys | |
from PySide6.QtWidgets import (QApplication, QMainWindow, QPushButton) | |
from PySide6.QtMultimedia import (QMediaCaptureSession, QAudioInput, QMediaRecorder) | |
class MicTest(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
self.recording = False | |
self.setWindowTitle("Mic Test") | |
# Make a start button | |
self.startButton = QPushButton("Record") | |
self.setCentralWidget(self.startButton) | |
self.startButton.clicked.connect(self.recordClicked) | |
# Make an audio input | |
self.m_audio = QAudioInput() | |
# Make a media recorder | |
self.m_mediaRecorder = QMediaRecorder() | |
self.m_mediaRecorder.setOutputLocation("mictest") | |
# Setup capture session | |
self.m_captureSession = QMediaCaptureSession() | |
self.m_captureSession.setAudioInput(self.m_audio) | |
self.m_captureSession.setRecorder(self.m_mediaRecorder) | |
# Record button clicked | |
def recordClicked(self): | |
if not self.recording: | |
self.m_mediaRecorder.record() | |
else: | |
self.m_mediaRecorder.stop() | |
self.recording = not self.recording | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
m = MicTest() | |
m.show() | |
sys.exit(app.exec()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PySide6==6.7.0 | |
PySide6_Addons==6.7.0 | |
PySide6_Essentials==6.7.0 | |
shiboken6==6.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PySide6==6.4.2 | |
PySide6-Addons==6.4.2 | |
PySide6-Essentials==6.4.2 | |
shiboken6==6.4.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup:
Then play the resulting
mictest.ma4
file