Spark808 commited on
Commit
a388cc2
·
1 Parent(s): 919609a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -7
app.py CHANGED
@@ -19,10 +19,17 @@ logging.getLogger("numba").setLevel(logging.WARNING)
19
 
20
 
21
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
22
- def vc_fn(vc_transpose, vc_f0method, vc_index_ratio):
 
 
 
 
 
 
 
23
  try:
24
  # Get the recorded audio from the microphone
25
- audio, sr = vc_microphone.record(num_frames=16000) # Adjust the sample rate if needed
26
 
27
  # Your existing processing logic for audio
28
  times = [0, 0, 0]
@@ -44,11 +51,13 @@ def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
44
  print(
45
  f"[{datetime.now().strftime('%Y-%m-%d %H:%M')}]: npy: {times[0]}, f0: {times[1]}s, infer: {times[2]}s"
46
  )
47
- return "Success", (tgt_sr, audio_opt)
48
- except:
 
49
  info = traceback.format_exc()
50
  print(info)
51
- return info, (None, None)
 
52
 
53
  return vc_fn
54
 
@@ -115,7 +124,7 @@ if __name__ == '__main__':
115
  gr.Markdown(
116
  '<div align="center">'
117
  f'<div>{title}</div>\n' +
118
- (f'<img style="width:auto;height:300px;" src="file/{cover}">' if cover else "") +
119
  '</div>'
120
  )
121
  with gr.Row():
@@ -141,5 +150,5 @@ if __name__ == '__main__':
141
  vc_output1 = gr.Textbox(label="Output Message")
142
  vc_output2 = gr.Audio(label="Output Audio")
143
 
144
- vc_submit.click(vc_fn, [vc_transpose, vc_f0method, vc_index_ratio], [vc_output1, vc_output2])
145
  app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)
 
19
 
20
 
21
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
22
+ def vc_fn(
23
+ vc_microphone,
24
+ vc_transpose,
25
+ vc_f0method,
26
+ vc_index_ratio,
27
+ vc_output1,
28
+ vc_output2
29
+ ):
30
  try:
31
  # Get the recorded audio from the microphone
32
+ audio, sr = vc_microphone()
33
 
34
  # Your existing processing logic for audio
35
  times = [0, 0, 0]
 
51
  print(
52
  f"[{datetime.now().strftime('%Y-%m-%d %H:%M')}]: npy: {times[0]}, f0: {times[1]}s, infer: {times[2]}s"
53
  )
54
+ vc_output1.update("Success")
55
+ vc_output2.update((tgt_sr, audio_opt))
56
+ except Exception as e:
57
  info = traceback.format_exc()
58
  print(info)
59
+ vc_output1.update(str(e))
60
+ vc_output2.update((None, None))
61
 
62
  return vc_fn
63
 
 
124
  gr.Markdown(
125
  '<div align="center">'
126
  f'<div>{title}</div>\n' +
127
+ (f'<img style="width:auto;height:300px;" src="file/{cover}">' if os.path.exists(cover) else "") +
128
  '</div>'
129
  )
130
  with gr.Row():
 
150
  vc_output1 = gr.Textbox(label="Output Message")
151
  vc_output2 = gr.Audio(label="Output Audio")
152
 
153
+ vc_submit.click(vc_fn, vc_microphone, vc_transpose, vc_f0method, vc_index_ratio, vc_output1, vc_output2)
154
  app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)