Skip to content

Commit

Permalink
perf: defer expensive imports to optimize readalongs -h
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Jan 3, 2024
1 parent d114cc5 commit baffdd4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion readalongs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from lxml import etree

from readalongs._version import __version__
from readalongs.align import align_audio, create_input_ras, save_readalong
from readalongs.log import LOGGER
from readalongs.text.add_ids_to_xml import add_ids
from readalongs.text.convert_xml import convert_xml
Expand Down Expand Up @@ -280,6 +279,9 @@ def align(**kwargs): # noqa: C901 # some versions of flake8 need this here ins
OUTPUT_BASE: Output files will be saved as OUTPUT_BASE/OUTPUT_BASE.*
"""
# deferred expensive imports
from readalongs.align import align_audio, create_input_ras, save_readalong

config_file = kwargs.get("config", None)
config = None
if config_file:
Expand Down Expand Up @@ -505,6 +507,8 @@ def make_xml(**kwargs):
XMLFILE: Path to the XML output file, or - for stdout [default: PLAINTEXTFILE.readalong]
"""
# deferred expensive import
from readalongs.align import create_input_ras

if kwargs["debug"]:
LOGGER.setLevel("DEBUG")
Expand Down

0 comments on commit baffdd4

Please sign in to comment.