Omnibus commited on
Commit
0f61089
1 Parent(s): fad8edf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  from transformers import AutoProcessor, BarkModel
4
  import scipy
5
  from pytube import YouTube
 
6
 
7
 
8
  # device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -40,6 +41,14 @@ def load_video_yt(vid):
40
  vid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename="tmp.mp4")
41
  vid_aud = yt.streams.filter(only_audio=True)[0].download(filename="tmp_aud.mp3")
42
  return vid, vid_aud
 
 
 
 
 
 
 
 
43
 
44
  with gr.Blocks() as app:
45
  with gr.Column():
@@ -56,6 +65,9 @@ with gr.Blocks() as app:
56
  with gr.Row():
57
  in_aud_yt = gr.Textbox(label="YouTube URL")
58
  load_yt_btn = gr.Button("Load URL")
 
 
 
59
  yt_vid = gr.Video()
60
  alt_go_btn = gr.Button()
61
  #speaker_num = gr.Number(value=0)
@@ -65,6 +77,7 @@ with gr.Blocks() as app:
65
 
66
  go_btn.click(run_bark,[in_text, speaker_num, speaker_lang],out_audio)
67
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file])
 
68
  #alt_go_btn.click()
69
 
70
  app.launch()
 
3
  from transformers import AutoProcessor, BarkModel
4
  import scipy
5
  from pytube import YouTube
6
+ import ffmpeg
7
 
8
 
9
  # device = "cuda" if torch.cuda.is_available() else "cpu"
 
41
  vid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename="tmp.mp4")
42
  vid_aud = yt.streams.filter(only_audio=True)[0].download(filename="tmp_aud.mp3")
43
  return vid, vid_aud
44
+
45
+ def trim_clip(clip):
46
+ start_pos = 1
47
+ duration = 10
48
+ audio_input = ffmpeg.input(url)
49
+ audio_output = ffmpeg.output(audio_input, save_location, ss=start_pos, t=duration)
50
+ audio_output.run()
51
+ return audio_output
52
 
53
  with gr.Blocks() as app:
54
  with gr.Column():
 
65
  with gr.Row():
66
  in_aud_yt = gr.Textbox(label="YouTube URL")
67
  load_yt_btn = gr.Button("Load URL")
68
+ with gr.Row():
69
+ trim_clip_btn = gr.Button("Trim Clip")\
70
+ trim_aud = gr.Audio(source='upload')
71
  yt_vid = gr.Video()
72
  alt_go_btn = gr.Button()
73
  #speaker_num = gr.Number(value=0)
 
77
 
78
  go_btn.click(run_bark,[in_text, speaker_num, speaker_lang],out_audio)
79
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file])
80
+ trim_clip_btn.click(trim_clip,None,trim_aud)
81
  #alt_go_btn.click()
82
 
83
  app.launch()