Madhuslista commited on
Commit
8ee91c9
·
1 Parent(s): 138226e

Feature: Add time measurements

Browse files
Files changed (1) hide show
  1. lib/model.py +13 -0
lib/model.py CHANGED
@@ -2,6 +2,7 @@
2
  # -*- coding: utf-8 -*-
3
 
4
  import gc
 
5
  import torch
6
  import whisperx as wx
7
 
@@ -27,13 +28,25 @@ def transcribe_audio(audio_file, audio_path, transcript_folder_path):
27
  # Transcribe the audio
28
  print("Starting transcription...")
29
  print("Loading model...")
 
30
  model = wx.load_model("large-v2", device=DEVICE, compute_type=COMPUTE_TYPE, language="en")
 
31
  print("Loading audio...")
 
32
  audio = wx.load_audio(audio_path)
 
33
  print("Transcribing...")
 
34
  result = model.transcribe(audio, batch_size=BATCH_SIZE)
 
35
  print("Transcription complete!")
36
 
 
 
 
 
 
 
37
  # Save the transcript to a file
38
  text = "\n ".join([i["text"] for i in result["segments"]])
39
 
 
2
  # -*- coding: utf-8 -*-
3
 
4
  import gc
5
+ from time import time
6
  import torch
7
  import whisperx as wx
8
 
 
28
  # Transcribe the audio
29
  print("Starting transcription...")
30
  print("Loading model...")
31
+ time_1 = time()
32
  model = wx.load_model("large-v2", device=DEVICE, compute_type=COMPUTE_TYPE, language="en")
33
+ time_2 = time()
34
  print("Loading audio...")
35
+ time_3 = time()
36
  audio = wx.load_audio(audio_path)
37
+ time_4 = time()
38
  print("Transcribing...")
39
+ time_5 = time()
40
  result = model.transcribe(audio, batch_size=BATCH_SIZE)
41
+ time_6 = time()
42
  print("Transcription complete!")
43
 
44
+ print("\nTime Report: ")
45
+ print("Loading model: ", round(time_2 - time_1,2), " [s]")
46
+ print("Loading audio: ", round(time_4 - time_3,2), " [s]")
47
+ print("Transcribing: ", round(time_6 - time_5,2), " [s]")
48
+ print("Total: ", round(time_6 - time_1,2), " [s]")
49
+
50
  # Save the transcript to a file
51
  text = "\n ".join([i["text"] for i in result["segments"]])
52