TheAnsIs42 commited on
Commit
de46850
·
2 Parent(s): 045f1d7 ab2fa9d

Merge branch 'eason/main' of https://github.com/project-kxkg/project-t into eason/main

Browse files
Files changed (1) hide show
  1. pipeline.py +3 -3
pipeline.py CHANGED
@@ -98,21 +98,21 @@ def get_srt_class(srt_file_en, result_path, video_name, audio_path, audio_file =
98
  # using whisper to perform speech-to-text and save it in <video name>_en.txt under RESULT PATH.
99
  srt_file_en = "{}/{}/{}_en.srt".format(result_path, video_name, video_name)
100
  if not os.path.exists(srt_file_en):
101
-
 
102
  # use OpenAI API for transcribe
103
  if method == "api":
104
  transcript = openai.Audio.transcribe("whisper-1", audio_file)
105
 
106
  # use local whisper model
107
  elif method == "basic":
108
- model = whisper.load_model(whisper_model) # using base model in local machine (may use large model on our server)
109
  transcript = model.transcribe(audio_path)
110
 
111
  # use stable-whisper
112
  elif method == "stable":
113
 
114
  # use cuda if available
115
- devices = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
116
  model = stable_whisper.load_model(whisper_model, device = devices)
117
  transcript = model.transcribe(audio_path, regroup = False, initial_prompt="Hello, welcome to my lecture. Are you good my friend?")
118
  (
 
98
  # using whisper to perform speech-to-text and save it in <video name>_en.txt under RESULT PATH.
99
  srt_file_en = "{}/{}/{}_en.srt".format(result_path, video_name, video_name)
100
  if not os.path.exists(srt_file_en):
101
+
102
+ devices = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
103
  # use OpenAI API for transcribe
104
  if method == "api":
105
  transcript = openai.Audio.transcribe("whisper-1", audio_file)
106
 
107
  # use local whisper model
108
  elif method == "basic":
109
+ model = whisper.load_model(whisper_model, device = devices) # using base model in local machine (may use large model on our server)
110
  transcript = model.transcribe(audio_path)
111
 
112
  # use stable-whisper
113
  elif method == "stable":
114
 
115
  # use cuda if available
 
116
  model = stable_whisper.load_model(whisper_model, device = devices)
117
  transcript = model.transcribe(audio_path, regroup = False, initial_prompt="Hello, welcome to my lecture. Are you good my friend?")
118
  (