SayaSS commited on
Commit
ad0b2b8
1 Parent(s): 929fb26

update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -14,6 +14,7 @@ logging.getLogger('markdown_it').setLevel(logging.WARNING)
14
  logging.getLogger('urllib3').setLevel(logging.WARNING)
15
  logging.getLogger('matplotlib').setLevel(logging.WARNING)
16
 
 
17
  def create_vc_fn(model, sid):
18
  def vc_fn(input_audio, vc_transform, auto_f0):
19
  if input_audio is None:
@@ -21,7 +22,7 @@ def create_vc_fn(model, sid):
21
  sampling_rate, audio = input_audio
22
  # print(audio.shape,sampling_rate)
23
  duration = audio.shape[0] / sampling_rate
24
- if duration > 45:
25
  return "Please upload an audio file that is less than 45 seconds. If you need to generate a longer audio file, please use Colab.", None
26
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
27
  if len(audio.shape) > 1:
@@ -70,7 +71,7 @@ if __name__ == '__main__':
70
  )
71
  with gr.Row():
72
  with gr.Column():
73
- vc_input = gr.Audio(label="Input audio (less than 45 seconds)")
74
  vc_transform = gr.Number(label="vc_transform", value=0)
75
  auto_f0 = gr.Checkbox(label="auto_f0", value=False)
76
  vc_submit = gr.Button("Generate", variant="primary")
 
14
  logging.getLogger('urllib3').setLevel(logging.WARNING)
15
  logging.getLogger('matplotlib').setLevel(logging.WARNING)
16
 
17
+ limitation = os.getenv("SYSTEM") == "spaces" # limit audio length in huggingface spaces
18
  def create_vc_fn(model, sid):
19
  def vc_fn(input_audio, vc_transform, auto_f0):
20
  if input_audio is None:
 
22
  sampling_rate, audio = input_audio
23
  # print(audio.shape,sampling_rate)
24
  duration = audio.shape[0] / sampling_rate
25
+ if duration > 45 and limitation:
26
  return "Please upload an audio file that is less than 45 seconds. If you need to generate a longer audio file, please use Colab.", None
27
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
28
  if len(audio.shape) > 1:
 
71
  )
72
  with gr.Row():
73
  with gr.Column():
74
+ vc_input = gr.Audio(label="Input audio"+' (less than 45 seconds)' if limitation else '')
75
  vc_transform = gr.Number(label="vc_transform", value=0)
76
  auto_f0 = gr.Checkbox(label="auto_f0", value=False)
77
  vc_submit = gr.Button("Generate", variant="primary")