Merge pull request #173 from FlippFuzz/fix-os-error-no-mic

Handle failure on systems without microphones
This commit is contained in:
makaveli
2024-03-11 14:50:15 +05:30
committed by GitHub
+4
View File
@@ -66,6 +66,7 @@ class Client:
self.timestamp_offset = 0.0 self.timestamp_offset = 0.0
self.audio_bytes = None self.audio_bytes = None
self.p = pyaudio.PyAudio() self.p = pyaudio.PyAudio()
try:
self.stream = self.p.open( self.stream = self.p.open(
format=self.format, format=self.format,
channels=self.channels, channels=self.channels,
@@ -73,6 +74,9 @@ class Client:
input=True, input=True,
frames_per_buffer=self.chunk, frames_per_buffer=self.chunk,
) )
except OSError as error:
print(f"[WARN]: Unable to access microphone. {error}")
self.stream = None
if host is not None and port is not None: if host is not None and port is not None:
socket_url = f"ws://{host}:{port}" socket_url = f"ws://{host}:{port}"