diff --git a/video_transcription/ai_transcriber_v2/__pycache__/diarizer.cpython-313.pyc b/video_transcription/ai_transcriber_v2/__pycache__/diarizer.cpython-313.pyc new file mode 100644 index 0000000..f530c17 Binary files /dev/null and b/video_transcription/ai_transcriber_v2/__pycache__/diarizer.cpython-313.pyc differ diff --git a/video_transcription/ai_transcriber_v2/diarizer.py b/video_transcription/ai_transcriber_v2/diarizer.py index 934324d..1a74307 100644 --- a/video_transcription/ai_transcriber_v2/diarizer.py +++ b/video_transcription/ai_transcriber_v2/diarizer.py @@ -6,31 +6,28 @@ import os import sys +import tracker +import torch def diarize_audio(audio_path, num_speakers=None, hf_token=None): """ Performs speaker diarization using pyannote.audio. - - Args: - audio_path (str): Path to audio file. - num_speakers (int, optional): Number of speakers if known. - hf_token (str): HuggingFace Auth Token. - - Returns: - list: List of segments with speaker labels [(start, end, speaker), ...]. """ try: from pyannote.audio import Pipeline except ImportError: - print("Error: pyannote.audio not installed. Diarization skipped.") + tracker.logger.error("Error: pyannote.audio not installed. Diarization skipped.") return None if not hf_token: - print("Error: HuggingFace Token (HF_TOKEN) not found. Diarization skipped.") + tracker.logger.error("Error: HuggingFace Token (HF_TOKEN) not found. Diarization skipped.") return None - print(f"Loading Diarization Pipeline (pyannote/speaker-diarization-3.1)...") + tracker.logger.info(f"Loading Diarization Pipeline (pyannote/speaker-diarization-3.1)...") try: + # Fix for PyTorch 2.6+ weights_only issue + torch.serialization.add_safe_globals([torch.torch_version.TorchVersion]) + # Note: 'use_auth_token' was deprecated in favor of 'token' in recent versions pipeline = Pipeline.from_pretrained( "pyannote/speaker-diarization-3.1", @@ -38,11 +35,10 @@ def diarize_audio(audio_path, num_speakers=None, hf_token=None): ) # Move to GPU if available - import torch if torch.cuda.is_available(): pipeline.to(torch.device("cuda")) - print(f"Diarizing {audio_path}...") + tracker.logger.info(f"Diarizing {audio_path}...") diarization = pipeline(audio_path, num_speakers=num_speakers) results = [] @@ -56,7 +52,7 @@ def diarize_audio(audio_path, num_speakers=None, hf_token=None): return results except Exception as e: - print(f"Error during diarization: {e}") + tracker.logger.error(f"Error during diarization: {e}") return None def merge_diarization_with_transcript(transcript_segments, diarization_segments): diff --git a/video_transcription/ai_transcriber_v2/documentation/HOW_TO_RUN_BACKGROUND.md b/video_transcription/ai_transcriber_v2/documentation/HOW_TO_RUN_BACKGROUND.md index 2547ba0..6bd7b3b 100644 --- a/video_transcription/ai_transcriber_v2/documentation/HOW_TO_RUN_BACKGROUND.md +++ b/video_transcription/ai_transcriber_v2/documentation/HOW_TO_RUN_BACKGROUND.md @@ -60,3 +60,31 @@ Here are the two best ways to do this. ```bash tail -f job_output.log ``` + +--- + +## Method 3: Rescuing a Running Job (The `disown` Method) +**Use this if:** You already started the wizard or script in a normal terminal and now realize you need to disconnect without killing it. + +1. **Pause the running job:** + Inside the terminal where the script is active, press **`Ctrl` + `Z`**. + * The script will pause, and you'll see: `[1]+ Stopped ...` + +2. **Move it to the background:** + Type the following command and press Enter: + ```bash + bg + ``` + * The script will resume running in the background. + +3. **Disown the job:** + Tell the terminal to "forget" about the job so it doesn't kill it when you disconnect: + ```bash + disown -h %1 + ``` + *(Note: Use `%1` if your job number was `[1]`, `%2` if it was `[2]`, etc.)* + +4. **Disconnect:** + You can now type `exit` or close your SSH window. The job will continue on the server. + +**Warning:** Unlike `tmux`, you cannot "reattach" to see the progress bar again. You must monitor the logs in the `logs/` folder to check its status. diff --git a/video_transcription/ai_transcriber_v2/translator.py b/video_transcription/ai_transcriber_v2/translator.py index 1118fb5..4ea1223 100644 --- a/video_transcription/ai_transcriber_v2/translator.py +++ b/video_transcription/ai_transcriber_v2/translator.py @@ -14,7 +14,7 @@ from utils import LANGUAGE_MAP # Define a retry decorator # ... (retry_policy remains) -def translate_via_ollama(source_srt_content, target_language="English", model="llama3"): +def translate_via_ollama(source_srt_content, target_language="English", model="dolphin-llama3"): """ Translates SRT content using a local Ollama model (Line-by-Line for progress). Includes retries and debug logging. diff --git a/video_transcription/ai_transcriber_v2/utils.py b/video_transcription/ai_transcriber_v2/utils.py index 7750f4f..499bbb0 100644 --- a/video_transcription/ai_transcriber_v2/utils.py +++ b/video_transcription/ai_transcriber_v2/utils.py @@ -70,7 +70,7 @@ def verify_file_not_empty(file_path): return True return False -def ensure_ollama_running(model_name="llama3"): +def ensure_ollama_running(model_name="dolphin-llama3"): """ Checks if Ollama is running. If not, attempts to start it. Supports Flatpak by escaping to host via flatpak-spawn.