Omnibus commited on
Commit
99954b1
1 Parent(s): a8e72fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -17
app.py CHANGED
@@ -46,7 +46,7 @@ def load_video_yt(vid):
46
  print (yt.length)
47
  return vid, vid_aud, "tmp_aud.mp4"
48
 
49
- def trim_clip(clip):
50
  clip = Path("tmp_aud.mp4")
51
  #clip = "tmp_aud.mp3"
52
  # Open an mp3 file
@@ -58,12 +58,15 @@ def trim_clip(clip):
58
  start_sec = 10
59
  end_min = 0
60
  end_sec = 55
61
-
 
 
 
62
  # pydub does things in milliseconds, so convert time
63
- #start = ((start_min*60)+start_sec)*1000
64
- #end = ((end_min*60)+end_sec)*1000
65
- start = 0
66
- end = 15*1000
67
  # song clip of 10 seconds from starting
68
  first_10_seconds = song[start: end]
69
 
@@ -82,16 +85,21 @@ with gr.Blocks() as app:
82
  speaker_lang = gr.Dropdown(label="Speaker Language", choices=lang_list,value="en")
83
  go_btn = gr.Button()
84
  with gr.Tab("Upload"):
85
- with gr.Row():
86
- in_aud_mic = gr.Audio(source='microphone')
87
- in_aud_file = gr.Audio(source='upload', interactive = True)
88
- aud_file = gr.File()
89
- with gr.Row():
90
- in_aud_yt = gr.Textbox(label="YouTube URL")
91
- load_yt_btn = gr.Button("Load URL")
92
- with gr.Row():
93
- trim_clip_btn = gr.Button("Trim Clip")
94
- trim_aud = gr.Audio(source='upload', interactive = False)
 
 
 
 
 
95
  yt_vid = gr.Video(type = 'filepath')
96
  trim_vid=gr.Video()
97
  alt_go_btn = gr.Button()
@@ -102,7 +110,7 @@ with gr.Blocks() as app:
102
 
103
  go_btn.click(run_bark,[in_text, speaker_num, speaker_lang],out_audio)
104
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file,aud_file])
105
- trim_clip_btn.click(trim_clip,aud_file,trim_aud)
106
  #alt_go_btn.click()
107
 
108
  app.launch()
 
46
  print (yt.length)
47
  return vid, vid_aud, "tmp_aud.mp4"
48
 
49
+ def trim_clip(clip, start_t, end_t):
50
  clip = Path("tmp_aud.mp4")
51
  #clip = "tmp_aud.mp3"
52
  # Open an mp3 file
 
58
  start_sec = 10
59
  end_min = 0
60
  end_sec = 55
61
+ start_min = int(start_t.split(":",1)[0])
62
+ start_sec = int(start_t.split(":",1)[1])
63
+ end_min = int(end_t.split(":",1)[0])
64
+ end_sec = int(end_t.split(":",1)[1])
65
  # pydub does things in milliseconds, so convert time
66
+ start = ((start_min*60)+start_sec)*1000
67
+ end = ((end_min*60)+end_sec)*1000
68
+ #start = 0
69
+ #end = 15*1000
70
  # song clip of 10 seconds from starting
71
  first_10_seconds = song[start: end]
72
 
 
85
  speaker_lang = gr.Dropdown(label="Speaker Language", choices=lang_list,value="en")
86
  go_btn = gr.Button()
87
  with gr.Tab("Upload"):
88
+ with gr.Box():
89
+ with gr.Column():
90
+ in_aud_mic = gr.Audio(source='microphone')
91
+ in_aud_file = gr.Audio(source='upload', interactive = True)
92
+ aud_file = gr.File()
93
+ with gr.Column():
94
+ in_aud_yt = gr.Textbox(label="YouTube URL")
95
+ load_yt_btn = gr.Button("Load URL")
96
+ with gr.Column():
97
+ with gr.Row():
98
+ start_time = gr.Textbox(label = "Start", value = "0:00", placeholder = "0:23")
99
+ end_time = gr.Textbox(label = "End", value = "0:01", placeholder = "1:12")
100
+
101
+ trim_clip_btn = gr.Button("Trim Clip")
102
+ trim_aud = gr.Audio(source='upload', interactive = False)
103
  yt_vid = gr.Video(type = 'filepath')
104
  trim_vid=gr.Video()
105
  alt_go_btn = gr.Button()
 
110
 
111
  go_btn.click(run_bark,[in_text, speaker_num, speaker_lang],out_audio)
112
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file,aud_file])
113
+ trim_clip_btn.click(trim_clip,[aud_file, start_time, end_time],trim_aud)
114
  #alt_go_btn.click()
115
 
116
  app.launch()