From 4d477e35e7ad36f6fe8a5b6bb659569593e69a97 Mon Sep 17 00:00:00 2001 From: FlippFuzz <41221030+FlippFuzz@users.noreply.github.com> Date: Sun, 10 Mar 2024 19:43:53 +0800 Subject: [PATCH 1/2] Handle failure on systems without microphones Catch the OSError and print a WARN log. --- whisper_live/client.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/whisper_live/client.py b/whisper_live/client.py index a759eae..5133266 100644 --- a/whisper_live/client.py +++ b/whisper_live/client.py @@ -66,13 +66,17 @@ class Client: self.timestamp_offset = 0.0 self.audio_bytes = None self.p = pyaudio.PyAudio() - self.stream = self.p.open( - format=self.format, - channels=self.channels, - rate=self.rate, - input=True, - frames_per_buffer=self.chunk, - ) + try: + self.stream = self.p.open( + format=self.format, + channels=self.channels, + rate=self.rate, + input=True, + 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: socket_url = f"ws://{host}:{port}" From 9b2e17ec4df3fd19df259e5216b5ae2ddbd119aa Mon Sep 17 00:00:00 2001 From: FlippFuzz <41221030+FlippFuzz@users.noreply.github.com> Date: Sun, 10 Mar 2024 20:28:54 +0800 Subject: [PATCH 2/2] Fix faster whisper version in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 652affb..0bc417b 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ setup( ), install_requires=[ "PyAudio", - "faster-whisper==0.10.0", + "faster-whisper==1.0.1", "torch", "torchaudio", "websockets",