more cleanup

This commit is contained in:
Karl 2024-07-13 09:56:21 +00:00
parent 7e83e4ef1e
commit 281b3cabc1
6 changed files with 21 additions and 23 deletions

7
.vscode/launch.json vendored
View File

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

View File

@ -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')",
)

View File

@ -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."

View File

@ -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

View File

@ -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

View File

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