Omnibus commited on
Commit
1567aff
1 Parent(s): bedfa5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -3,7 +3,7 @@ import torch
3
  from transformers import AutoProcessor, BarkModel
4
  import scipy
5
  from pytube import YouTube
6
- from moviepy.editor import *
7
 
8
  #import ffmpeg
9
 
@@ -45,17 +45,29 @@ def load_video_yt(vid):
45
  return vid, vid_aud
46
 
47
  def trim_clip(clip):
48
-
49
- # loading video dsa gfg intro video
50
- clip = VideoFileClip(clip)
51
-
52
- # getting only first 5 seconds
53
- clip = clip.subclip(0, 15)
54
-
55
- # cutting out some part from the clip
56
- clip = clip.cutout(3, 10)
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- return clip
59
 
60
  with gr.Blocks() as app:
61
  with gr.Column():
 
3
  from transformers import AutoProcessor, BarkModel
4
  import scipy
5
  from pytube import YouTube
6
+ from pydub import AudioSegment
7
 
8
  #import ffmpeg
9
 
 
45
  return vid, vid_aud
46
 
47
  def trim_clip(clip):
48
+
49
+ # Open an mp3 file
50
+ song = AudioSegment.from_file(clip,
51
+ format="mp3")
52
+
53
+ # start and end time
54
+ start_min = 0
55
+ start_sec = 10
56
+ end_min = 0
57
+ end_sec = 55
58
+
59
+ # pydub does things in milliseconds, so convert time
60
+ start = ((start_min*60)+start_sec)*1000
61
+ end = ((end_min*60)+end_sec)*1000
62
+
63
+ # song clip of 10 seconds from starting
64
+ first_10_seconds = song[start: end]
65
+
66
+ # save file
67
+ first_10_seconds.export("Mid.mp3", format="mp3")
68
+ print("New Audio file is created and saved")
69
 
70
+ return "Mid.mp3"
71
 
72
  with gr.Blocks() as app:
73
  with gr.Column():