Neprox commited on
Commit
98a9509
1 Parent(s): c1c59f8
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -11,11 +11,11 @@ def download_from_youtube(url):
11
  fpath = streams.first().download()
12
  return fpath
13
 
14
- def create_30s_segments(fpath):
15
  if not os.path.exists("segmented_audios"):
16
  os.makedirs("segmented_audios")
17
 
18
- sound = AudioFileClip(fpath)
19
  n_full_segments = int(sound.duration / 30)
20
  len_last_segment = sound.duration % 30
21
 
@@ -40,11 +40,13 @@ def create_30s_segments(fpath):
40
  segment_paths.append(segment_path)
41
  segment_start_times.append(start)
42
 
 
 
43
 
44
  def transcribe(audio, url):
45
  if url:
46
  fpath = download_from_youtube(url)
47
- audio_segment_paths = create_30s_segments(fpath)
48
 
49
  audio_dataset = Dataset.from_dict({"audio": audio_segment_paths}).cast_column("audio", Audio())
50
  print(audio_dataset)
 
11
  fpath = streams.first().download()
12
  return fpath
13
 
14
+ def divide_into_30s_segments(audio_fpath):
15
  if not os.path.exists("segmented_audios"):
16
  os.makedirs("segmented_audios")
17
 
18
+ sound = AudioFileClip(audio_fpath)
19
  n_full_segments = int(sound.duration / 30)
20
  len_last_segment = sound.duration % 30
21
 
 
40
  segment_paths.append(segment_path)
41
  segment_start_times.append(start)
42
 
43
+ return segment_paths, segment_start_times
44
+
45
 
46
  def transcribe(audio, url):
47
  if url:
48
  fpath = download_from_youtube(url)
49
+ segment_paths, segment_start_times = divide_into_30s_segments(fpath)
50
 
51
  audio_dataset = Dataset.from_dict({"audio": audio_segment_paths}).cast_column("audio", Audio())
52
  print(audio_dataset)