Omnibus commited on
Commit
6d2a0cf
1 Parent(s): 20d75a9

Update vc.py

Browse files
Files changed (1) hide show
  1. vc.py +17 -7
vc.py CHANGED
@@ -51,7 +51,7 @@ def bark_ez(text, n='1', land='en'):
51
  return (f'{uid}-output.wav')
52
 
53
 
54
- def custom_bark(inp, tog, in_aud=None, trim_aud=None, in_aud_mic=None):
55
  if tog=="Custom":
56
  if in_aud_mic != None:
57
  speaker_wav=in_aud_mic
@@ -64,7 +64,7 @@ def custom_bark(inp, tog, in_aud=None, trim_aud=None, in_aud_mic=None):
64
  tts.tts_to_file(inp, speaker_wav=speaker_wav, language="en", file_path=f"{uid}-output.wav")
65
  return (f"{uid}-output.wav")
66
  if tog=="Preset":
67
- return (bark_ez(inp))
68
  def load_video_yt(vid):
69
  yt = YouTube(vid)
70
  vid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename=f"{uid}-tmp.mp4")
@@ -93,6 +93,13 @@ def pre_aud(inp):
93
  song.export(f"{uid}-tmp_aud.mp4", format="mp4")
94
  print(f'pre_aud:: {f"{uid}-tmp_aud.mp4"}')
95
  return inp
 
 
 
 
 
 
 
96
  with gr.Blocks() as app:
97
  with gr.Group():
98
  with gr.Row():
@@ -100,11 +107,14 @@ with gr.Blocks() as app:
100
  with gr.Column():
101
  alt_go_btn = gr.Button()
102
  out_audio = gr.Audio(interactive=False)
103
- with gr.Group():
104
  with gr.Row():
105
  gr.Markdown('''<H1> Audio Source:''')
106
  with gr.Row():
107
- tog = gr.Radio(label="Input Type", choices=["Preset","Custom"], value="Preset")
 
 
 
108
  with gr.Row():
109
  with gr.Column():
110
 
@@ -121,11 +131,11 @@ with gr.Blocks() as app:
121
  load_yt_btn = gr.Button("Load URL")
122
  yt_vid = gr.Video(interactive=False)
123
 
124
-
125
-
126
  #in_aud_file.change(pre_aud,in_aud_file,aud_file)
127
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file,aud_file])
128
  trim_clip_btn.click(trim_clip,[in_aud_file, start_time, end_time],trim_aud)
129
- alt_go_btn.click(custom_bark, [in_text,tog,in_aud_file,trim_aud], out_audio)
130
 
131
  app.launch()
 
51
  return (f'{uid}-output.wav')
52
 
53
 
54
+ def custom_bark(inp, tog, speaker,in_aud=None, trim_aud=None, in_aud_mic=None):
55
  if tog=="Custom":
56
  if in_aud_mic != None:
57
  speaker_wav=in_aud_mic
 
64
  tts.tts_to_file(inp, speaker_wav=speaker_wav, language="en", file_path=f"{uid}-output.wav")
65
  return (f"{uid}-output.wav")
66
  if tog=="Preset":
67
+ return (bark_ez(inp,speaker))
68
  def load_video_yt(vid):
69
  yt = YouTube(vid)
70
  vid = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename=f"{uid}-tmp.mp4")
 
93
  song.export(f"{uid}-tmp_aud.mp4", format="mp4")
94
  print(f'pre_aud:: {f"{uid}-tmp_aud.mp4"}')
95
  return inp
96
+ def tog_in(tog):
97
+ if tog=="Preset":
98
+ return (gr.update(visible=True),gr.update(visible=False))
99
+ if tog=="Custom":
100
+ return (gr.update(visible=False),gr.update(visible=True))
101
+
102
+
103
  with gr.Blocks() as app:
104
  with gr.Group():
105
  with gr.Row():
 
107
  with gr.Column():
108
  alt_go_btn = gr.Button()
109
  out_audio = gr.Audio(interactive=False)
110
+
111
  with gr.Row():
112
  gr.Markdown('''<H1> Audio Source:''')
113
  with gr.Row():
114
+ tog = gr.Radio(label="Input Type", choices=["Preset","Custom"], value="Preset")
115
+ with gr.Group(visible=True) as group_1:
116
+ speaker_num = gr.Dropdown(label="Speaker Voice", choices=num_list,value="1")
117
+ with gr.Group(visible=False) as group_2:
118
  with gr.Row():
119
  with gr.Column():
120
 
 
131
  load_yt_btn = gr.Button("Load URL")
132
  yt_vid = gr.Video(interactive=False)
133
 
134
+
135
+ tog.change(tog_in,tog,[group_1,group_2])
136
  #in_aud_file.change(pre_aud,in_aud_file,aud_file)
137
  load_yt_btn.click(load_video_yt, in_aud_yt, [yt_vid,in_aud_file,aud_file])
138
  trim_clip_btn.click(trim_clip,[in_aud_file, start_time, end_time],trim_aud)
139
+ alt_go_btn.click(custom_bark, [in_text,tog,speaker_num,in_aud_file,trim_aud], out_audio)
140
 
141
  app.launch()