changes to run when audio playback is muted

This commit is contained in:
Kiran Lonikar
2025-07-07 13:21:20 +05:30
committed by GitHub
parent 9954548075
commit e597c876cf
+14 -9
View File
@@ -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: