jhtonyKoo commited on
Commit
7748d49
1 Parent(s): df8bacd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -25,7 +25,7 @@ yt_video_dir = "./yt_dir/0"
25
  os.makedirs(yt_video_dir, exist_ok=True)
26
 
27
 
28
- def get_audio_from_yt_video_input(yt_link: str):
29
  try:
30
  yt = pt.YouTube(yt_link)
31
  t = yt.streams.filter(only_audio=True)
@@ -35,9 +35,12 @@ def get_audio_from_yt_video_input(yt_link: str):
35
  warnings.warn(f"Video Not Found at {yt_link} ({e})")
36
  filename_in = None
37
 
 
 
 
38
  return filename_in, filename_in
39
 
40
- def get_audio_from_yt_video_ref(yt_link: str):
41
  try:
42
  yt = pt.YouTube(yt_link)
43
  t = yt.streams.filter(only_audio=True)
@@ -47,6 +50,9 @@ def get_audio_from_yt_video_ref(yt_link: str):
47
  warnings.warn(f"Video Not Found at {yt_link} ({e})")
48
  filename_ref = None
49
 
 
 
 
50
  return filename_ref, filename_ref
51
 
52
  def inference(file_uploaded_in, file_uploaded_ref):
 
25
  os.makedirs(yt_video_dir, exist_ok=True)
26
 
27
 
28
+ def get_audio_from_yt_video_input(yt_link: str, start_point_in_second=0, duration_in_second=30):
29
  try:
30
  yt = pt.YouTube(yt_link)
31
  t = yt.streams.filter(only_audio=True)
 
35
  warnings.warn(f"Video Not Found at {yt_link} ({e})")
36
  filename_in = None
37
 
38
+ # trim audio length - due to computation time on HuggingFace environment
39
+ trim_audio(target_file_path=filename_in, start_point_in_second=start_point_in_second, duration_in_second=duration_in_second)
40
+
41
  return filename_in, filename_in
42
 
43
+ def get_audio_from_yt_video_ref(yt_link: str, start_point_in_second=0, duration_in_second=30):
44
  try:
45
  yt = pt.YouTube(yt_link)
46
  t = yt.streams.filter(only_audio=True)
 
50
  warnings.warn(f"Video Not Found at {yt_link} ({e})")
51
  filename_ref = None
52
 
53
+ # trim audio length - due to computation time on HuggingFace environment
54
+ trim_audio(target_file_path=filename_ref, start_point_in_second=start_point_in_second, duration_in_second=duration_in_second)
55
+
56
  return filename_ref, filename_ref
57
 
58
  def inference(file_uploaded_in, file_uploaded_ref):