DJQmUKV commited on
Commit
1d04a59
1 Parent(s): ee904a2

feat: add audio conversion length limit

Browse files
Files changed (1) hide show
  1. app_multi.py +10 -3
app_multi.py CHANGED
@@ -1,10 +1,8 @@
1
  from typing import Union
2
 
3
- from argparse import ArgumentParser
4
-
5
  import asyncio
6
  import json
7
- from os import path
8
 
9
  import gradio as gr
10
 
@@ -24,6 +22,10 @@ from infer_pack.models import (
24
  from vc_infer_pipeline import VC
25
 
26
 
 
 
 
 
27
  app_css = '''
28
  #model_info img {
29
  max-width: 100px;
@@ -113,6 +115,11 @@ def vc_func(input_audio, model_index, pitch_adjust, f0_method, feat_ratio):
113
 
114
  # Reference: so-vits
115
  (audio_samp, audio_npy) = input_audio
 
 
 
 
 
116
  # Bloody hell: https://stackoverflow.com/questions/26921836/
117
  if audio_npy.dtype != np.float32: # :thonk:
118
  audio_npy = (
 
1
  from typing import Union
2
 
 
 
3
  import asyncio
4
  import json
5
+ from os import path, getenv
6
 
7
  import gradio as gr
8
 
 
22
  from vc_infer_pipeline import VC
23
 
24
 
25
+ # Reference: https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L21 # noqa
26
+ in_hf_space = getenv('SYSTEM') == 'spaces'
27
+
28
+
29
  app_css = '''
30
  #model_info img {
31
  max-width: 100px;
 
115
 
116
  # Reference: so-vits
117
  (audio_samp, audio_npy) = input_audio
118
+
119
+ # https://huggingface.co/spaces/zomehwh/rvc-models/blob/main/app.py#L49
120
+ if (audio_npy.shape[0] / audio_samp) > 30 and in_hf_space:
121
+ return (None, 'Input audio is longer than 30 secs.')
122
+
123
  # Bloody hell: https://stackoverflow.com/questions/26921836/
124
  if audio_npy.dtype != np.float32: # :thonk:
125
  audio_npy = (