Spaces:
Build error
Build error
Update inference.py
Browse files- inference.py +2 -2
inference.py
CHANGED
|
@@ -60,14 +60,14 @@ def infer(f,r,speaker,key,reqf0=False):
|
|
| 60 |
file=r
|
| 61 |
else:
|
| 62 |
return "请上传音频", None
|
| 63 |
-
sr
|
| 64 |
if sr<16000:
|
| 65 |
return "采样率过低,请上传至少拥有16000Hz采样率的音频",None
|
| 66 |
duration = audio.shape[0] / sr
|
| 67 |
print(audio.shape,sr,duration)
|
| 68 |
if duration > 120:
|
| 69 |
return "请上传小于2min的音频", None
|
| 70 |
-
audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
|
| 71 |
x,sourcef0 = get_text(audio,sr,getkey(key))
|
| 72 |
x_lengths = [np.size(x,1)]
|
| 73 |
print(x_lengths[0],sr,speaker,key)
|
|
|
|
| 60 |
file=r
|
| 61 |
else:
|
| 62 |
return "请上传音频", None
|
| 63 |
+
audio,sr = librosa.load(file,sr=None)
|
| 64 |
if sr<16000:
|
| 65 |
return "采样率过低,请上传至少拥有16000Hz采样率的音频",None
|
| 66 |
duration = audio.shape[0] / sr
|
| 67 |
print(audio.shape,sr,duration)
|
| 68 |
if duration > 120:
|
| 69 |
return "请上传小于2min的音频", None
|
| 70 |
+
#audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
|
| 71 |
x,sourcef0 = get_text(audio,sr,getkey(key))
|
| 72 |
x_lengths = [np.size(x,1)]
|
| 73 |
print(x_lengths[0],sr,speaker,key)
|