Exemple #1
0
    def __init__(self):
        super(ZeguiWindow, self).__init__()
        self.setWindowTitle("Zegui")

        # microphone input (placeholder for the data streams)
        self.audioDevice = QAudioDeviceInfo.defaultInputDevice()
        if (self.audioDevice.isNull()):
            QMessageBox.warning(None, "audio", "There is no audio input device available.")
            sys.exit(-1)

        # File information
        #self.currSession = RecordingSession('','')

        # Status bar
        self.status = self.statusBar()

        # Menu
        self.createActions()
        self.createMenu()

        # Window dimension
        geometry = app.desktop().availableGeometry(self)
        self.setFixedSize(geometry.width() * 0.8, geometry.height() * 0.7)

        # Widget with panels
        self.zewidget = ZeWidget(self.audioDevice)
        self.setCentralWidget(self.zewidget)
Exemple #2
0
    def __init__(self, default_device_name):
        super().__init__()
        self.default_device_name = default_device_name
        self._pull_timer = QTimer()
        self._pull_timer.setInterval(3000)
        self._pull_timer.timeout.connect(self.write_to_buffer)

        self._audio_input = None
        self._input = None
        self._audio_data_handler = None

        devices = QAudioDeviceInfo.availableDevices(QAudio.AudioInput)
        self._device = None
        self.monitors = []

        for item in devices:
            dev_name = item.deviceName()
            if dev_name.endswith(".monitor"):
                self.monitors.append(item)
            if self.default_device_name and self.default_device_name == item.deviceName(
            ):
                self._device = item
        if not self._device:
            try:
                self._device = self.monitors[0]
            except IndexError:
                self._device = QAudioDeviceInfo.defaultInputDevice()

        self.initialize_audio()

        self.start_audio()
Exemple #3
0
    def __init__(self, inference_thread):
        super(Dialog, self).__init__()
        self._btn = QPushButton('Record', self)
        self._label = QLabel('', self)

        layout = QVBoxLayout()
        layout.addWidget(self._btn)
        layout.addWidget(self._label)
        self.setLayout(layout)

        self._btn.clicked.connect(self._btn_clicked)
        self._is_recording = False

        self._inference_thread = inference_thread
        self._inference_thread.finished.connect(
            self._on_transcription_finished)

        audio_format = QAudioFormat()
        audio_format.setCodec('audio/pcm')
        audio_format.setChannelCount(1)
        audio_format.setSampleSize(16)
        audio_format.setSampleRate(16000)
        audio_format.setByteOrder(QAudioFormat.LittleEndian)
        audio_format.setSampleType(QAudioFormat.SignedInt)

        input_device_info = QAudioDeviceInfo.defaultInputDevice()
        if not input_device_info.isFormatSupported(audio_format):
            print('Can\'t record audio in 16kHz 16-bit signed PCM format.')
            exit(1)

        self._audio_input = QAudioInput(audio_format)
Exemple #4
0
 def change_audio_input(self, input_name):
     input_devices = self.monitors
     input_devices.append(QAudioDeviceInfo.defaultInputDevice())
     for i in range(len(input_devices)):
         if input_devices[i].deviceName() == input_name:
             self._device = input_devices[i]
             self.initialize_audio()
             self.start_audio()
             break
Exemple #5
0
 def get_input_devices(self):
     devices = []
     if self._device:
         devices.append(self._device)
     for item in self.monitors:
         if item.deviceName() not in [x.deviceName() for x in devices]:
             devices.append(item)
     system_default = QAudioDeviceInfo.defaultInputDevice()
     if system_default not in [x.deviceName() for x in devices]:
         devices.append(system_default)
     return devices
Exemple #6
0
 def interfaces(self):
     self.devices = QAudioDeviceInfo.availableDevices(QAudio.AudioInput)
     self.default = QAudioDeviceInfo.defaultInputDevice()
     print(self.default.supportedCodecs())
Exemple #7
0
        start = 0
        if (availableSamples < sampleCount):
            start = sampleCount - availableSamples
            for s in range(start):
                self.buffer[s].setY(self.buffer[s + availableSamples].y())

        dataIndex = 0
        for s in range(start, sampleCount):
            value = (ord(data[dataIndex]) - 128) / 128
            self.buffer[s].setY(value)
            dataIndex = dataIndex + resolution
        self.series.replace(self.buffer)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    inputDevice = QAudioDeviceInfo.defaultInputDevice()
    if (inputDevice.isNull()):
        QMessageBox.warning(None, "audio",
                            "There is no audio input device available.")
        sys.exit(-1)

    mainWin = MainWindow(inputDevice)
    mainWin.setWindowTitle("audio")
    availableGeometry = app.desktop().availableGeometry(mainWin)
    size = availableGeometry.height() * 3 / 4
    mainWin.resize(size, size)
    mainWin.show()
    sys.exit(app.exec_())
Exemple #8
0
        data = self.ioDevice.readAll()
        availableSamples = data.size() // resolution
        start = 0
        if (availableSamples < sampleCount):
            start = sampleCount - availableSamples
            for s in range(start):
                self.buffer[s].setY(self.buffer[s + availableSamples].y())

        dataIndex = 0
        for s in range(start, sampleCount):
            value = (ord(data[dataIndex]) - 128) / 128
            self.buffer[s].setY(value)
            dataIndex = dataIndex + resolution
        self.series.replace(self.buffer)

if __name__ == '__main__':
    app = QApplication(sys.argv)

    inputDevice = QAudioDeviceInfo.defaultInputDevice()
    if (inputDevice.isNull()):
        QMessageBox.warning(None, "audio", "There is no audio input device available.")
        sys.exit(-1)

    mainWin = MainWindow(inputDevice)
    mainWin.setWindowTitle("audio")
    availableGeometry = app.desktop().availableGeometry(mainWin)
    size = availableGeometry.height() * 3 / 4
    mainWin.resize(size, size)
    mainWin.show()
    sys.exit(app.exec_())