From eab8181ecc958d933830bbb1658b8e1b3a18a8d4 Mon Sep 17 00:00:00 2001 From: mkuehne-git Date: Wed, 2 Aug 2023 22:22:55 +0200 Subject: [PATCH 1/3] Initialize input_device_index when opening pyaudio stream --- manim_voiceover/services/recorder/utility.py | 1 + 1 file changed, 1 insertion(+) diff --git a/manim_voiceover/services/recorder/utility.py b/manim_voiceover/services/recorder/utility.py index 006c202..14e593b 100644 --- a/manim_voiceover/services/recorder/utility.py +++ b/manim_voiceover/services/recorder/utility.py @@ -165,6 +165,7 @@ def _record_task(self, path): channels=self.channels, rate=self.rate, input=True, + input_device_index=self.device_index, frames_per_buffer=self.chunk, stream_callback=self.callback, ) From 5aa0b6dd1e4ff899697db07c9a6808e5118c2bc8 Mon Sep 17 00:00:00 2001 From: mkuehne-git Date: Sat, 5 Aug 2023 16:30:48 +0200 Subject: [PATCH 2/3] Fix initialization of rate and channels. --- manim_voiceover/services/recorder/utility.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/manim_voiceover/services/recorder/utility.py b/manim_voiceover/services/recorder/utility.py index 14e593b..509ab0c 100644 --- a/manim_voiceover/services/recorder/utility.py +++ b/manim_voiceover/services/recorder/utility.py @@ -141,6 +141,7 @@ def _set_device(self): 0, self.device_index ).get("name") self._set_channels_from_device_index(self.device_index) + self._set_rate_from_device_index(self.device_index) print("Selected device:", device_name) except KeyboardInterrupt: print("KeyboardInterrupt") @@ -152,9 +153,22 @@ def _set_device(self): return def _set_channels_from_device_index(self, device_index): - self.channels = self.audio.get_device_info_by_host_api_device_index( + channels_from_device = self.audio.get_device_info_by_host_api_device_index( 0, device_index ).get("maxInputChannels") + if self.channels is None: + self.channels = channels_from_device + else: + self.channels = min(self.channels, channels_from_device) + + def _set_rate_from_device_index(self, device_index): + rate_from_device = self.audio.get_device_info_by_host_api_device_index( + 0, device_index + ).get("defaultSampleRate") + if self.rate is None: + self.rate = int(rate_from_device) + else: + self.rate = int(min(self.rate, rate_from_device)) def _record_task(self, path): if self.listener.key_pressed and not self.started: From 5074815a2a3b6cd94be05fa853e85e69e0c32487 Mon Sep 17 00:00:00 2001 From: mkuehne-git Date: Mon, 4 Sep 2023 16:43:33 +0200 Subject: [PATCH 3/3] Fix: No subcaptions if save_lastframe is True --- manim_voiceover/voiceover_scene.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manim_voiceover/voiceover_scene.py b/manim_voiceover/voiceover_scene.py index 16524f2..687bb29 100644 --- a/manim_voiceover/voiceover_scene.py +++ b/manim_voiceover/voiceover_scene.py @@ -32,11 +32,15 @@ def set_speech_service( Args: speech_service (SpeechService): The speech service to be used. - create_subcaption (bool, optional): Whether to create subcaptions for the scene. Defaults to True. + create_subcaption (bool, optional): Whether to create subcaptions for the scene. Defaults to True. If `config.save_last_frame` is True, the argument is + ignored and no subcaptions will be created. """ self.speech_service = speech_service self.current_tracker = None - self.create_subcaption = create_subcaption + if config.save_last_frame: + self.create_subcaption = False + else: + self.create_subcaption = create_subcaption def add_voiceover_text( self,