Karl преди 8 месеца
родител
ревизия
281b3cabc1
променени са 6 файла, в които са добавени 21 реда и са изтрити 23 реда
  1. 5 2
      .vscode/launch.json
  2. 0 1
      bazarr-ai-sub-generator/cli.py
  3. 3 18
      bazarr-ai-sub-generator/main.py
  4. 13 0
      bazarr-ai-sub-generator/utils/decorator.py
  5. 0 1
      requirements.txt
  6. 0 1
      setup.py

+ 5 - 2
.vscode/launch.json

@@ -11,12 +11,15 @@
             "program": "${file}",
             "console": "integratedTerminal",
             "justMyCode": false,
+            "env": {
+                "CUDA_VISIBLE_DEVICES": "1"
+            },
             "args": [
                 "--model",
                 "base",
                 "--show",
                 "Gary Neville's Soccerbox"
-            ],
+            ]
         }
     ]
-}
+}

+ 0 - 1
bazarr-ai-sub-generator/cli.py

@@ -77,7 +77,6 @@ def main():
         "--show",
         type=str,
         default=None,
-        #choices=["transcribe", "translate"],
         help="whether to perform X->X speech recognition ('transcribe') \
                               or X->English translation ('translate')",
     )

+ 3 - 18
bazarr-ai-sub-generator/main.py

@@ -7,27 +7,14 @@ from utils.ffmpeg import get_audio, add_subtitles_to_mp4
 from utils.bazarr import get_wanted_episodes, get_episode_details, sync_series
 from utils.sonarr import update_show_in_sonarr
 from utils.whisper import WhisperAI
-
-def measure_time(func):
-    def wrapper(*args, **kwargs):
-        start_time = time.time()
-        result = func(*args, **kwargs)
-        end_time = time.time()
-        duration = end_time - start_time
-        print(f"Function '{func.__name__}' executed in: {duration:.6f} seconds")
-        return result
-    return wrapper
-
-
+from utils.decorator import measure_time
 
 def process(args: dict):
     
     model_name: str = args.pop("model")
     language: str = args.pop("language")
     show: str = args.pop("show")
-    # sample_interval: str = args.pop("sample_interval")
-    # audio_channel: str = args.pop("audio_channel")
-
+    
     if model_name.endswith(".en"):
         warnings.warn(
             f"{model_name} is an English-only model, forcing English detection."
@@ -38,10 +25,8 @@ def process(args: dict):
         args["language"] = language
 
     model_args = {}
-    # model_args["model_size_or_path"] = model_name
     model_args["device"] = args.pop("device")
-    # model_args["compute_type"] = args.pop("compute_type")
-
+    
     list_of_episodes_needing_subtitles = get_wanted_episodes(show)
     print(
         f"Found {list_of_episodes_needing_subtitles['total']} episodes needing subtitles."

+ 13 - 0
bazarr-ai-sub-generator/utils/decorator.py

@@ -0,0 +1,13 @@
+import time
+from datetime import timedelta
+
+def measure_time(func):
+    def wrapper(*args, **kwargs):
+        start_time = time.time()
+        result = func(*args, **kwargs)
+        end_time = time.time()
+        duration = end_time - start_time
+        human_readable_duration = str(timedelta(seconds=duration))
+        print(f"Function '{func.__name__}' executed in: {human_readable_duration}")
+        return result
+    return wrapper

+ 0 - 1
requirements.txt

@@ -1,4 +1,3 @@
-faster-whisper==0.10.0
 tqdm==4.56.0
 ffmpeg-python==0.2.0
 git+https://github.com/openai/whisper.git

+ 0 - 1
setup.py

@@ -7,7 +7,6 @@ setup(
     py_modules=["bazarr-ai-sub-generator"],
     author="Karl Hudgell",
     install_requires=[
-        'faster-whisper',
         'tqdm',
         'ffmpeg-python'
     ],