Skip to content

Commit

Permalink
Run black, fix elevenlabs import issue
Browse files Browse the repository at this point in the history
  • Loading branch information
osolmaz committed Feb 25, 2024
1 parent 575530b commit f082e05
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
4 changes: 3 additions & 1 deletion examples/openai-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
20 changes: 5 additions & 15 deletions examples/quadratic-formula-arabic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions manim_voiceover/services/elevenlabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions manim_voiceover/services/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def __init__(
"""
Args:
voice (str, optional): The voice to use. See the
`API page <https://platform.openai.com/docs/api-reference/audio/createSpeech>`__
for all the available options. Defaults to ``"alloy"``.
`API page <https://platform.openai.com/docs/api-reference/audio/createSpeech>`__
for all the available options. Defaults to ``"alloy"``.
model (str, optional): The TTS model to use.
See the `API page <https://platform.openai.com/docs/api-reference/audio/createSpeech>`__
for all the available options. Defaults to ``"tts-1-hd"``.
See the `API page <https://platform.openai.com/docs/api-reference/audio/createSpeech>`__
for all the available options. Defaults to ``"tts-1-hd"``.
"""
prompt_ask_missing_extras("openai", "openai", "OpenAIService")
self.voice = voice
Expand Down

0 comments on commit f082e05

Please sign in to comment.