From e597c876cf231dd8e80a236e794e039d3ab22e83 Mon Sep 17 00:00:00 2001 From: Kiran Lonikar Date: Mon, 7 Jul 2025 13:21:20 +0530 Subject: [PATCH] changes to run when audio playback is muted --- whisper_live/client.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/whisper_live/client.py b/whisper_live/client.py index 5bd51d6..197afb9 100644 --- a/whisper_live/client.py +++ b/whisper_live/client.py @@ -420,14 +420,18 @@ class TranscriptionTeeClient: # read audio and create pyaudio stream with wave.open(filename, "rb") as wavfile: - self.stream = self.p.open( - format=self.p.get_format_from_width(wavfile.getsampwidth()), - channels=wavfile.getnchannels(), - rate=wavfile.getframerate(), - input=True, - output=True, - frames_per_buffer=self.chunk, - ) + if self.mute_audio_playback: + self.stream = None + else: + self.stream = self.p.open( + format=self.p.get_format_from_width(wavfile.getsampwidth()), + channels=wavfile.getnchannels(), + rate=wavfile.getframerate(), + input=True, + output=True, + frames_per_buffer=self.chunk, + ) + chunk_duration = self.chunk / float(wavfile.getframerate()) try: while any(client.recording for client in self.clients): @@ -448,7 +452,8 @@ class TranscriptionTeeClient: client.wait_before_disconnect() self.multicast_packet(Client.END_OF_AUDIO.encode('utf-8'), True) self.write_all_clients_srt() - self.stream.close() + if self.stream: + self.stream.close() self.close_all_clients() except KeyboardInterrupt: