Skip to content

Commit

Permalink
fix macos version
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed May 19, 2023
1 parent 82a6d7c commit dff7089
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
"PyQt6==6.3.1",
"webvtt-py==0.4.6",
"appdirs==1.4.4",
"disklru>=1.0.2"
"disklru>=1.0.5"
]

dynamic = ["version"]
Expand Down
6 changes: 3 additions & 3 deletions src/video_subtitles/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

from appdirs import user_config_dir # type: ignore
from disklru import DiskLRUCache # type: ignore
import torch.cuda

from video_subtitles.convert_to_webvtt import convert_to_webvtt as convert_webvtt
from video_subtitles.translate import srt_wrap, translate
from video_subtitles.util import read_utf8

IS_GITHUB = os.environ.get("GITHUB_ACTIONS", False)
ALLOW_CONCURRENT_TRANSLATION = False

CACHE_FILE = os.path.join(user_config_dir("video-subtitles", "cache", roaming=True))
Expand Down Expand Up @@ -58,7 +58,6 @@ def run( # pylint: disable=too-many-locals,too-many-branches,too-many-statement
raise RuntimeError(
f"File {os.path.basename(file)} cannot contain spaces at the beginning or end"
)

cache = DiskLRUCache(CACHE_FILE, 16)
file = os.path.abspath(file)
print("Running transcription")
Expand All @@ -69,7 +68,8 @@ def run( # pylint: disable=too-many-locals,too-many-branches,too-many-statement
print("Done running transcription")
if deepl_api_key == "free":
deepl_api_key = None
device = "cuda" if not IS_GITHUB else "cpu"
has_cuda = torch.cuda.is_available()
device = "cuda" if has_cuda else "cpu"
filemd5 = md5(file.encode("utf-8")).hexdigest()
key = f"{file}-{filemd5}-{model}"
cached_data = cache.get_json(key)
Expand Down
4 changes: 3 additions & 1 deletion src/video_subtitles/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def ensure_transcribe_anything_installed() -> None:
)
rtn = subprocess.call(["python", os.path.join(tempdir, "install_cuda.py")])
if rtn != 0:
raise RuntimeError("install_cuda.py failed.") # pylint: disable=raise-missing-from
raise RuntimeError( # pylint: disable=raise-missing-from
"install_cuda.py failed."
) # pylint: disable=raise-missing-from


def parse_languages(languages_str: str) -> list[str]:
Expand Down

0 comments on commit dff7089

Please sign in to comment.