|
@@ -3,7 +3,7 @@ import warnings
|
|
|
import tempfile
|
|
|
import time
|
|
|
from utils.files import filename, write_srt
|
|
|
-from utils.ffmpeg import get_audio, add_subs_new
|
|
|
+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_soarr
|
|
|
from utils.whisper import WhisperAI
|
|
@@ -11,15 +11,10 @@ from utils.whisper import WhisperAI
|
|
|
|
|
|
def process(args: dict):
|
|
|
model_name: str = args.pop("model")
|
|
|
- output_dir: str = args.pop("output_dir")
|
|
|
- output_srt: bool = args.pop("output_srt")
|
|
|
- srt_only: bool = args.pop("srt_only")
|
|
|
language: str = args.pop("language")
|
|
|
sample_interval: str = args.pop("sample_interval")
|
|
|
audio_channel: str = args.pop('audio_channel')
|
|
|
|
|
|
- os.makedirs(output_dir, exist_ok=True)
|
|
|
-
|
|
|
if model_name.endswith(".en"):
|
|
|
warnings.warn(
|
|
|
f"{model_name} is an English-only model, forcing English detection.")
|
|
@@ -39,19 +34,14 @@ def process(args: dict):
|
|
|
print(f"Processing {episode['seriesTitle']} - {episode['episode_number']}")
|
|
|
episode_data = get_episode_details(episode['sonarrEpisodeId'])
|
|
|
audios = get_audio([episode_data['path']], audio_channel, sample_interval)
|
|
|
- srt_output_dir = output_dir if output_srt or srt_only else tempfile.gettempdir()
|
|
|
- subtitles = get_subtitles(audios, srt_output_dir, model_args, args)
|
|
|
-
|
|
|
- if srt_only:
|
|
|
- return
|
|
|
+ subtitles = get_subtitles(audios, tempfile.gettempdir(), model_args, args)
|
|
|
|
|
|
- add_subs_new(subtitles)
|
|
|
+ add_subtitles_to_mp4(subtitles)
|
|
|
update_show_in_soarr(episode['sonarrSeriesId'])
|
|
|
time.sleep(5)
|
|
|
sync_series()
|
|
|
|
|
|
|
|
|
-
|
|
|
def get_subtitles(audio_paths: list, output_dir: str,
|
|
|
model_args: dict, transcribe_args: dict):
|
|
|
model = WhisperAI(model_args, transcribe_args)
|