From 44b36801ed1a597a6b523990e603e0a03283d78e Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Thu, 20 Jun 2024 00:56:12 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B[bugfix]=20Model=20:=20speaker=20ch?= =?UTF-8?q?annel=20audio=5Fsources["channels"]=20>=3D=202=20=E3=81=AE?= =?UTF-8?q?=E6=99=82sample=5Frate=E3=82=92=E8=AA=BF=E6=95=B4=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/transcription/transcription_transcriber.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/models/transcription/transcription_transcriber.py b/models/transcription/transcription_transcriber.py index 3766b826..c1856b34 100644 --- a/models/transcription/transcription_transcriber.py +++ b/models/transcription/transcription_transcriber.py @@ -97,11 +97,19 @@ class AudioTranscriber: return audio_data def processSpeakerData(self): + original_channels = self.audio_sources["channels"] + if original_channels <= 2: + channels = original_channels + sample_rate = self.audio_sources["sample_rate"] + else: + channels = 2 + sample_rate = self.audio_sources["sample_rate"]*original_channels/2 + temp_file = BytesIO() with wave.open(temp_file, 'wb') as wf: - wf.setnchannels(2) + wf.setnchannels(channels) wf.setsampwidth(get_sample_size(paInt16)) - wf.setframerate(self.audio_sources["sample_rate"]) + wf.setframerate(sample_rate) wf.writeframes(self.audio_sources["last_sample"]) temp_file.seek(0) with AudioFile(temp_file) as source: