Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import sys
|
|
| 5 |
sys.path.append('.')
|
| 6 |
import gradio as gr
|
| 7 |
os.system('pip install -U torchtext==0.8.0')
|
|
|
|
| 8 |
#os.system('python setup.py install --install-dir .')
|
| 9 |
from scipy.io import wavfile
|
| 10 |
|
|
@@ -14,6 +15,11 @@ os.system('chmod a+x ./scripts/*/*.sh')
|
|
| 14 |
os.system('./separate_scripts/download_checkpoints.sh')
|
| 15 |
|
| 16 |
def inference(audio):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# read the file and get the sample rate and data
|
| 18 |
rate, data = wavfile.read(audio.name)
|
| 19 |
|
|
|
|
| 5 |
sys.path.append('.')
|
| 6 |
import gradio as gr
|
| 7 |
os.system('pip install -U torchtext==0.8.0')
|
| 8 |
+
os.system('pip install pydub') # 添加对pydub库的依赖
|
| 9 |
#os.system('python setup.py install --install-dir .')
|
| 10 |
from scipy.io import wavfile
|
| 11 |
|
|
|
|
| 15 |
os.system('./separate_scripts/download_checkpoints.sh')
|
| 16 |
|
| 17 |
def inference(audio):
|
| 18 |
+
# convert mp3 to wav if needed
|
| 19 |
+
if audio.name.endswith(".mp3"):
|
| 20 |
+
audio_wav = audio.name[:-4] + ".wav"
|
| 21 |
+
AudioSegment.from_file(audio.name).export(audio_wav, format="wav")
|
| 22 |
+
audio.name = audio_wav
|
| 23 |
# read the file and get the sample rate and data
|
| 24 |
rate, data = wavfile.read(audio.name)
|
| 25 |
|