Spaces:
Build error
Build error
Update inference.py
Browse files- inference.py +4 -4
inference.py
CHANGED
@@ -30,10 +30,8 @@ def _calculate_f0(input: np.ndarray,length,sr,f0min,f0max,
|
|
30 |
def get_text(wav,sr,transform=1.0):
|
31 |
|
32 |
#wav, sr = librosa.load(file,sr=None)
|
33 |
-
if sr<16000:
|
34 |
-
return 'sample rate too low'
|
35 |
if len(wav.shape) > 1:
|
36 |
-
wav = librosa.to_mono(wav)
|
37 |
if sr!=16000:
|
38 |
wav16 = librosa.resample(wav, sr, 16000)
|
39 |
else:
|
@@ -57,8 +55,10 @@ def getkey(key):
|
|
57 |
def infer(f,speaker,key,reqf0=False):
|
58 |
speaker=int(speaker[7:])
|
59 |
if f is None:
|
60 |
-
return "
|
61 |
sr, audio = f
|
|
|
|
|
62 |
duration = audio.shape[0] / sr
|
63 |
if duration > 120:
|
64 |
return "请上传小于2min的音频", None
|
|
|
30 |
def get_text(wav,sr,transform=1.0):
|
31 |
|
32 |
#wav, sr = librosa.load(file,sr=None)
|
|
|
|
|
33 |
if len(wav.shape) > 1:
|
34 |
+
wav = librosa.to_mono(wav.transpose(1, 0))
|
35 |
if sr!=16000:
|
36 |
wav16 = librosa.resample(wav, sr, 16000)
|
37 |
else:
|
|
|
55 |
def infer(f,speaker,key,reqf0=False):
|
56 |
speaker=int(speaker[7:])
|
57 |
if f is None:
|
58 |
+
return "请上传音频", None
|
59 |
sr, audio = f
|
60 |
+
if sr<16000:
|
61 |
+
return "采样率过低,请上传至少拥有16000Hz采样率的音频",None
|
62 |
duration = audio.shape[0] / sr
|
63 |
if duration > 120:
|
64 |
return "请上传小于2min的音频", None
|