Spark808 commited on
Commit
fed52c0
·
1 Parent(s): 54919b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -8,6 +8,7 @@ from datetime import datetime
8
  import gradio as gr
9
  import torch
10
  from fairseq import checkpoint_utils
 
11
 
12
  from infer_pack.models import SynthesizerTrnMs256NSFsid, SynthesizerTrnMs256NSFsid_nono
13
  from vc_infer_pipeline import VC
@@ -17,10 +18,10 @@ logging.getLogger("numba").setLevel(logging.WARNING)
17
 
18
 
19
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
20
- def vc_fn(vc_microphone, vc_transpose, vc_f0method, vc_index_ratio):
21
  try:
22
- # Get the recorded audio from the microphone
23
- audio, sr = vc_microphone.record(num_frames=16000) # Adjust the sample rate if needed
24
 
25
  # Your existing processing logic for audio
26
  times = [0, 0, 0]
@@ -118,8 +119,8 @@ if __name__ == '__main__':
118
  )
119
  with gr.Row():
120
  with gr.Column():
121
- # Use microphone instead of file upload
122
- vc_microphone = gr.Microphone(label="Record your voice")
123
  vc_transpose = gr.Number(label="Transpose", value=0)
124
  vc_f0method = gr.Radio(
125
  label="Pitch extraction algorithm, PM is fast but Harvest is better for low frequencies",
@@ -139,5 +140,5 @@ if __name__ == '__main__':
139
  vc_output1 = gr.Textbox(label="Output Message")
140
  vc_output2 = gr.Audio(label="Output Audio")
141
 
142
- vc_submit.click(vc_fn, [vc_microphone, vc_transpose, vc_f0method, vc_index_ratio], [vc_output1, vc_output2])
143
- app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)
 
8
  import gradio as gr
9
  import torch
10
  from fairseq import checkpoint_utils
11
+ import librosa
12
 
13
  from infer_pack.models import SynthesizerTrnMs256NSFsid, SynthesizerTrnMs256NSFsid_nono
14
  from vc_infer_pipeline import VC
 
18
 
19
 
20
  def create_vc_fn(tgt_sr, net_g, vc, if_f0, file_index, file_big_npy):
21
+ def vc_fn(vc_audio_file, vc_transpose, vc_f0method, vc_index_ratio):
22
  try:
23
+ # Load the audio file uploaded via Gradio
24
+ audio, sr = librosa.load(vc_audio_file.name, sr=None, mono=True)
25
 
26
  # Your existing processing logic for audio
27
  times = [0, 0, 0]
 
119
  )
120
  with gr.Row():
121
  with gr.Column():
122
+ # Use file upload instead of microphone
123
+ vc_audio_file = gr.File(label="Upload your audio file", type="audio")
124
  vc_transpose = gr.Number(label="Transpose", value=0)
125
  vc_f0method = gr.Radio(
126
  label="Pitch extraction algorithm, PM is fast but Harvest is better for low frequencies",
 
140
  vc_output1 = gr.Textbox(label="Output Message")
141
  vc_output2 = gr.Audio(label="Output Audio")
142
 
143
+ vc_submit.click(vc_fn, [vc_audio_file, vc_transpose, vc_f0method, vc_index_ratio], [vc_output1, vc_output2])
144
+ app.queue(concurrency_count=1, max_size=20, api_open=args.api).launch(share=args.share)