Set the stream mode to input (microphone/file) or output (speakers/file). Args: mode: The I/O mode (input or output). Returns: Current mode value.
(self, mode)
| 106 | self.sample_bits = None |
| 107 | |
| 108 | def _setMode(self, mode): |
| 109 | """ |
| 110 | Set the stream mode to input (microphone/file) or output (speakers/file). |
| 111 | |
| 112 | Args: |
| 113 | mode: The I/O mode (input or output). |
| 114 | Returns: |
| 115 | Current mode value. |
| 116 | """ |
| 117 | if mode == MODE_AUDIO_INPUT: |
| 118 | self.mode = MODE_AUDIO_INPUT |
| 119 | logger.info("_setMode: set stream mode to Input") |
| 120 | |
| 121 | elif mode == MODE_AUDIO_OUTPUT: |
| 122 | self.mode = MODE_AUDIO_OUTPUT |
| 123 | logger.info("_setMode: set stream mode to Output") |
| 124 | |
| 125 | else: |
| 126 | logger.error(f"_setMode: invalid mode {mode}, keeping current mode") |
| 127 | |
| 128 | return self.mode |
| 129 | |
| 130 | def _setDevice(self, device): |
| 131 | """ |