Skip to content

Commit

Permalink
fix macos
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed May 19, 2023
1 parent dff7089 commit cb662d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/video_subtitles/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

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
Expand Down Expand Up @@ -53,6 +52,7 @@ def run( # pylint: disable=too-many-locals,too-many-branches,too-many-statement
from transcribe_anything.api import ( # pylint: disable=import-outside-toplevel
transcribe,
)
from transcribe_anything.util import get_computing_device # pylint: disable=import-outside-toplevel

if file != file.strip():
raise RuntimeError(
Expand All @@ -68,8 +68,7 @@ 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
has_cuda = torch.cuda.is_available()
device = "cuda" if has_cuda else "cpu"
device = get_computing_device()
filemd5 = md5(file.encode("utf-8")).hexdigest()
key = f"{file}-{filemd5}-{model}"
cached_data = cache.get_json(key)
Expand Down
4 changes: 2 additions & 2 deletions src/video_subtitles/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import json
import os

from appdirs import user_config_dir # type: ignore
from appdirs import user_cache_dir # type: ignore

HERE = os.path.dirname(os.path.abspath(__file__))


def get_settings_path() -> str:
"""Get settings path"""
env_path = user_config_dir("video-subtitles", "video-subtitles", roaming=True)
env_path = user_cache_dir("video-subtitles", "video-subtitles")
config_file = os.path.join(env_path, "settings.json")
os.makedirs(env_path, exist_ok=True)
return config_file
Expand Down

0 comments on commit cb662d0

Please sign in to comment.