juancopi81 commited on
Commit
7e62c39
1 Parent(s): 6ca06af

Add start second

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -34,7 +34,7 @@ def change_model(model):
34
  current_model = model
35
 
36
  # Credits https://huggingface.co/spaces/rajesh1729/youtube-video-transcription-with-whisper
37
- def get_audio(url, start):
38
  yt = YouTube(url)
39
  video = yt.streams.filter(only_audio=True).first()
40
  out_file = video.download(output_path=".")
@@ -45,7 +45,8 @@ def get_audio(url, start):
45
  wav_to_cut = AudioSegment.from_file(a)
46
  # pydub does things in milliseconds
47
  ten_seconds = 10 * 1000
48
- first_10_seconds = wav_to_cut[start:start+ten_seconds]
 
49
  os.remove(new_file)
50
  first_10_seconds.export("final_audio.wav", format="wav")
51
  return "final_audio.wav"
 
34
  current_model = model
35
 
36
  # Credits https://huggingface.co/spaces/rajesh1729/youtube-video-transcription-with-whisper
37
+ def get_audio(url, start_second):
38
  yt = YouTube(url)
39
  video = yt.streams.filter(only_audio=True).first()
40
  out_file = video.download(output_path=".")
 
45
  wav_to_cut = AudioSegment.from_file(a)
46
  # pydub does things in milliseconds
47
  ten_seconds = 10 * 1000
48
+ print("Start second", start_second)
49
+ first_10_seconds = wav_to_cut[start_second:start_second+ten_seconds]
50
  os.remove(new_file)
51
  first_10_seconds.export("final_audio.wav", format="wav")
52
  return "final_audio.wav"