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 # read audio and create pyaudio stream
with wave.open(filename, "rb") as wavfile: with wave.open(filename, "rb") as wavfile:
self.stream = self.p.open( if self.mute_audio_playback:
format=self.p.get_format_from_width(wavfile.getsampwidth()), self.stream = None
channels=wavfile.getnchannels(), else:
rate=wavfile.getframerate(), self.stream = self.p.open(
input=True, format=self.p.get_format_from_width(wavfile.getsampwidth()),
output=True, channels=wavfile.getnchannels(),
frames_per_buffer=self.chunk, rate=wavfile.getframerate(),
) input=True,
output=True,
frames_per_buffer=self.chunk,
)
chunk_duration = self.chunk / float(wavfile.getframerate()) chunk_duration = self.chunk / float(wavfile.getframerate())
try: try:
while any(client.recording for client in self.clients): while any(client.recording for client in self.clients):
@@ -448,7 +452,8 @@ class TranscriptionTeeClient:
client.wait_before_disconnect() client.wait_before_disconnect()
self.multicast_packet(Client.END_OF_AUDIO.encode('utf-8'), True) self.multicast_packet(Client.END_OF_AUDIO.encode('utf-8'), True)
self.write_all_clients_srt() self.write_all_clients_srt()
self.stream.close() if self.stream:
self.stream.close()
self.close_all_clients() self.close_all_clients()
except KeyboardInterrupt: except KeyboardInterrupt: