From f082e05d8f085ab8cecf75963ef89e7c47622520 Mon Sep 17 00:00:00 2001 From: Onur Solmaz <2453968+osolmaz@users.noreply.github.com> Date: Sun, 25 Feb 2024 19:20:37 +0100 Subject: [PATCH] Run black, fix elevenlabs import issue --- examples/openai-example.py | 4 +++- examples/quadratic-formula-arabic.py | 20 +++++--------------- manim_voiceover/services/elevenlabs.py | 3 +-- manim_voiceover/services/openai.py | 8 ++++---- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/examples/openai-example.py b/examples/openai-example.py index b87127a..b7aeb28 100644 --- a/examples/openai-example.py +++ b/examples/openai-example.py @@ -24,7 +24,9 @@ def construct(self): with self.voiceover(text="Now, let's transform it into a square.") as tracker: self.play(Transform(circle, square), run_time=tracker.duration) - with self.voiceover(text="Thank you for watching.", speed=0.75): # You can also change the audio speed by specifying the speed argument. + with self.voiceover( + text="Thank you for watching.", speed=0.75 + ): # You can also change the audio speed by specifying the speed argument. self.play(Uncreate(circle)) self.wait() diff --git a/examples/quadratic-formula-arabic.py b/examples/quadratic-formula-arabic.py index 22dd472..c3e79ad 100644 --- a/examples/quadratic-formula-arabic.py +++ b/examples/quadratic-formula-arabic.py @@ -384,9 +384,7 @@ def construct(self): self.play(FadeIn(equation, shift=DOWN)) self.wait(0.2) - with self.voiceover( - text="بِحَيْثُ a b c أَعْدَادٌ حَقِيقِيَّةٌ، وَ a غَيْر مُنْعَدِمٍ." - ) as tracker: + with self.voiceover(text="بِحَيْثُ a b c أَعْدَادٌ حَقِيقِيَّةٌ، وَ a غَيْر مُنْعَدِمٍ.") as tracker: self.play(ReplacementTransform(equation[0].copy(), text)) self.wait() @@ -399,9 +397,7 @@ def construct(self): with self.voiceover(text="نَقُومُ بِمُضَاعَفَةِ b، ") as tracker: self.play(TransformMatchingShapes(eq1, eq2, path_arc=PI / 3)) - with self.voiceover( - text=" وَنَقْسِمُهُ عَلَى 2، كَيْ نُحَافِظَ عَلَى الْمُعَادَلَةِ." - ) as tracker: + with self.voiceover(text=" وَنَقْسِمُهُ عَلَى 2، كَيْ نُحَافِظَ عَلَى الْمُعَادَلَةِ.") as tracker: self.play(TransformMatchingShapes(eq2, eq3, path_arc=PI / 3)) self.wait() @@ -436,9 +432,7 @@ def construct(self): TransformMatchingShapes(eq5[2:], eq6[4]), ) - with self.voiceover( - text="وَ الآنَ، تَعْمِيلُ الْمُتَطَابِقَةِ الْهَامَّةُ" - ) as tracker: + with self.voiceover(text="وَ الآنَ، تَعْمِيلُ الْمُتَطَابِقَةِ الْهَامَّةُ") as tracker: self.play(Indicate(eq6[0:2], color=RED)) self.wait(2) @@ -479,18 +473,14 @@ def construct(self): self.play(ind_eq92) self.wait(0.3) - with self.voiceover( - text="نَضَعُ دِلْتَا يُسَاوِي الْبَسْطْ، b مُرَبَّعْ نَاقِصْ 4 a c." - ) as tracker: + with self.voiceover(text="نَضَعُ دِلْتَا يُسَاوِي الْبَسْطْ، b مُرَبَّعْ نَاقِصْ 4 a c.") as tracker: self.play( TransformFromCopy(delta, onpose[1][2:8]), Write(VGroup(onpose[0], onpose[1][0:2], onpose[8:])), lag_ratio=0.5, ) self.wait(0.3) - with self.voiceover( - text="دِلْتَا يُسَمَّى: مُمَيِّزُ الْمُعَادَلَةِ E" - ) as tracker: + with self.voiceover(text="دِلْتَا يُسَمَّى: مُمَيِّزُ الْمُعَادَلَةِ E") as tracker: self.wait(tracker.duration) # TODO You have to color the solutions set and formulas for cases diff --git a/manim_voiceover/services/elevenlabs.py b/manim_voiceover/services/elevenlabs.py index 222b4ba..0f94c9a 100644 --- a/manim_voiceover/services/elevenlabs.py +++ b/manim_voiceover/services/elevenlabs.py @@ -9,14 +9,13 @@ from manim_voiceover.helper import create_dotenv_file try: - import elevenlabs + from elevenlabs import Voice, VoiceSettings, generate, save, voices except ImportError: logger.error( 'Missing packages. Run `pip install "manim-voiceover[elevenlabs]"` ' "to use ElevenLabs API." ) -from elevenlabs import Voice, VoiceSettings, generate, save, voices from manim_voiceover.helper import create_dotenv_file, remove_bookmarks from manim_voiceover.services.base import SpeechService diff --git a/manim_voiceover/services/openai.py b/manim_voiceover/services/openai.py index 1198a42..263edac 100644 --- a/manim_voiceover/services/openai.py +++ b/manim_voiceover/services/openai.py @@ -54,11 +54,11 @@ def __init__( """ Args: voice (str, optional): The voice to use. See the - `API page `__ - for all the available options. Defaults to ``"alloy"``. + `API page `__ + for all the available options. Defaults to ``"alloy"``. model (str, optional): The TTS model to use. - See the `API page `__ - for all the available options. Defaults to ``"tts-1-hd"``. + See the `API page `__ + for all the available options. Defaults to ``"tts-1-hd"``. """ prompt_ask_missing_extras("openai", "openai", "OpenAIService") self.voice = voice