ubuntu@ubuntu-virtual-machine:~/Downloads$ python3 transcribe.py
/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/core/io.py:43: UserWarning: torchaudio._backend.set_audio_backend has been deprecated. With dispatcher enabled, this function is no-op. You can remove the function call.
  torchaudio.set_audio_backend("soundfile")
/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/pipelines/speaker_verification.py:43: UserWarning: torchaudio._backend.get_audio_backend has been deprecated. With dispatcher enabled, this function is no-op. You can remove the function call.
  backend = torchaudio.get_audio_backend()
INFO:speechbrain.utils.quirks:Applied quirks (see `speechbrain.utils.quirks`): [allow_tf32, disable_jit_profiling]
INFO:speechbrain.utils.quirks:Excluded quirks specified by the `SB_DISABLE_QUIRKS` environment (comma-separated list): []
/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/pipelines/speaker_verification.py:45: UserWarning: Module 'speechbrain.pretrained' was deprecated, redirecting to 'speechbrain.inference'. Please update your script. This is a change from SpeechBrain 1.0. See: https://github.com/speechbrain/speechbrain/releases/tag/v1.0.0
  from speechbrain.pretrained import (
/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/pipelines/speaker_verification.py:53: UserWarning: torchaudio._backend.set_audio_backend has been deprecated. With dispatcher enabled, this function is no-op. You can remove the function call.
  torchaudio.set_audio_backend(backend)
/home/ubuntu/.local/lib/python3.10/site-packages/pyannote/audio/tasks/segmentation/mixins.py:37: UserWarning: `torchaudio.backend.common.AudioMetaData` has been moved to `torchaudio.AudioMetaData`. Please update the import path.
  from torchaudio.backend.common import AudioMetaData

Processing with base model...
No language specified, language will be first be detected for each audio file (increases inference time).
/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:47: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
Model was trained with pyannote.audio 0.0.1, yours is 3.1.1. Bad things might happen unless you revert pyannote.audio to 0.x.
Model was trained with torch 1.10.0+cu102, yours is 2.5.1. Bad things might happen unless you revert torch to 1.x.
Detected language: en (0.72) in first 30s of audio...
Error processing base: string indices must be integers

Processing with base.en model...
/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:47: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
Model was trained with pyannote.audio 0.0.1, yours is 3.1.1. Bad things might happen unless you revert pyannote.audio to 0.x.
Model was trained with torch 1.10.0+cu102, yours is 2.5.1. Bad things might happen unless you revert torch to 1.x.
Error processing base.en: string indices must be integers

Processing with small model...
No language specified, language will be first be detected for each audio file (increases inference time).
/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:47: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
Model was trained with pyannote.audio 0.0.1, yours is 3.1.1. Bad things might happen unless you revert pyannote.audio to 0.x.
Model was trained with torch 1.10.0+cu102, yours is 2.5.1. Bad things might happen unless you revert torch to 1.x.
Detected language: en (0.81) in first 30s of audio...
^CError processing small: string indices must be integers

Processing with small.en model...
/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_lightning/utilities/cloud_io.py:47: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
Model was trained with pyannote.audio 0.0.1, yours is 3.1.1. Bad things might happen unless you revert pyannote.audio to 0.x.
Model was trained with torch 1.10.0+cu102, yours is 2.5.1. Bad things might happen unless you revert torch to 1.x.


# transcribe.py

import whisperx
import os
from datetime import datetime
import time
import torch

# Path to your audio file
audio_path = os.path.expanduser("~/Downloads/audio.mp3")

# Create main output directory
output_base_dir = "whisperx_outputs"
os.makedirs(output_base_dir, exist_ok=True)

# Function to transcribe and save results
def transcribe_with_model(model_name, device="cpu"):
    print(f"\nProcessing with {model_name} model...")
    start_time = time.time()

    # Create model-specific directory
    model_dir = os.path.join(output_base_dir, model_name)
    os.makedirs(model_dir, exist_ok=True)

    # Load model with compute_type set to "float32"
    model = whisperx.load_model(model_name, device=device, compute_type="float32")

    # Transcribe the audio
    segments, info = model.transcribe(audio_path)

    # Extract the full transcription text
    full_text = ' '.join([segment['text'] for segment in segments])

    # Save output
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    output_file = os.path.join(model_dir, f"transcript_{timestamp}.txt")

    with open(output_file, 'w', encoding='utf-8') as f:
        f.write(full_text)

    end_time = time.time()
    print(f"{model_name} processing time: {end_time - start_time:.2f} seconds")
    print(f"Output saved to: {output_file}")

# Process with all models including medium and medium.en
models = ["base", "base.en", "small", "small.en", "medium", "medium.en"]

for model_name in models:
    try:
        transcribe_with_model(model_name)
    except Exception as e:
        print(f"Error processing {model_name}: {e}")

print("\nAll processing complete! Check the whisperx_outputs directory for results.")