juancopi81 commited on
Commit
a717b8a
·
1 Parent(s): fd2477f

Update transforming/whispertransform.py

Browse files
Files changed (1) hide show
  1. transforming/whispertransform.py +7 -8
transforming/whispertransform.py CHANGED
@@ -30,16 +30,15 @@ class WhisperTransform(Transform):
30
  """Creates a new video with transcriptions created by Whisper.
31
  """
32
  # Create a YouTube object
33
- yt = YouTube(video.url)
34
-
35
- # Get audio from video
36
  try:
37
- audio_file = self._get_audio_from_video(yt)
38
-
39
- except Exception as e:
40
- audio_file = None
41
  print(f"Exception: {e}")
42
-
 
 
 
43
  result = self.model.transcribe(audio_file,
44
  without_timestamps=self.without_timestamps)
45
  transcription = result["text"]
 
30
  """Creates a new video with transcriptions created by Whisper.
31
  """
32
  # Create a YouTube object
 
 
 
33
  try:
34
+ yt = YouTube(video.url)
35
+ except (Exception):
36
+ print ("Video not available \n")
 
37
  print(f"Exception: {e}")
38
+ # Get audio from video
39
+ else:
40
+ audio_file = self._get_audio_from_video(yt)
41
+
42
  result = self.model.transcribe(audio_file,
43
  without_timestamps=self.without_timestamps)
44
  transcription = result["text"]