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).
100%|█████████████████████████████████████| 16.9M/16.9M [00:12<00:00, 1.46MiB/s]
Lightning automatically upgraded your loaded checkpoint from v1.5.4 to v2.4.0. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint ../.cache/torch/whisperx-vad-segmentation.bin`
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: 'text'

Processing with base.en model...
Lightning automatically upgraded your loaded checkpoint from v1.5.4 to v2.4.0. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint ../.cache/torch/whisperx-vad-segmentation.bin`
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: 'text'

Processing with small model...
No language specified, language will be first be detected for each audio file (increases inference time).
Lightning automatically upgraded your loaded checkpoint from v1.5.4 to v2.4.0. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint ../.cache/torch/whisperx-vad-segmentation.bin`
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...
Error processing small: 'text'

Processing with small.en model...
Lightning automatically upgraded your loaded checkpoint from v1.5.4 to v2.4.0. To apply the upgrade to your files permanently, run `python -m pytorch_lightning.utilities.upgrade_checkpoint ../.cache/torch/whisperx-vad-segmentation.bin`
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 small.en: 'text'

Processing with medium model...
^CTraceback (most recent call last):
  File "/home/ubuntu/Downloads/transcribe.py", line 45, in <module>
    transcribe_with_model(model_name)
  File "/home/ubuntu/Downloads/transcribe.py", line 24, in transcribe_with_model
    model = whisperx.load_model(model_name, device=device, compute_type="float32")
  File "/home/ubuntu/.local/lib/python3.10/site-packages/whisperx/asr.py", line 288, in load_model
    model = model or WhisperModel(whisper_arch,
  File "/home/ubuntu/.local/lib/python3.10/site-packages/faster_whisper/transcribe.py", line 127, in __init__
    model_path = download_model(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/faster_whisper/utils.py", line 103, in download_model
    return huggingface_hub.snapshot_download(repo_id, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/_snapshot_download.py", line 155, in snapshot_download
    repo_info = api.repo_info(repo_id=repo_id, repo_type=repo_type, revision=revision, token=token)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 2756, in repo_info
    return method(
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 2540, in model_info
    r = get_session().get(path, headers=headers, timeout=timeout, params=params)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 557, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 544, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 657, in send
    r = adapter.send(request, **kwargs)
  File "/home/ubuntu/.local/lib/python3.10/site-packages/huggingface_hub/utils/_http.py", line 93, in send
    return super().send(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 700, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 446, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 441, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1375, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.10/ssl.py", line 1303, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.10/ssl.py", line 1159, in read
    return self._sslobj.read(len, buffer)
KeyboardInterrupt
ubuntu@ubuntu-virtual-machine:~/Downloads$ 

script : 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
    result = model.transcribe(audio_path)
    
    # 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(result["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.")