Ksjsjjdj commited on
Commit
cbf8a8f
·
verified ·
1 Parent(s): 8862368

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -6,7 +6,8 @@ from pathlib import Path
6
 
7
  def install_dependencies():
8
  commands = [
9
- "pip install spaces-0.1.0-py3-none-any.whl"
 
10
  ]
11
  for cmd in commands:
12
  os.system(cmd)
@@ -18,6 +19,7 @@ from PIL import Image
18
  import soundfile as sf
19
  import torch
20
  import gradio as gr
 
21
  from huggingface_hub import snapshot_download
22
 
23
  try:
@@ -40,16 +42,7 @@ pipe = None
40
 
41
  def load_audio_for_model(audio_filepath):
42
  try:
43
- wav, sr = sf.read(audio_filepath)
44
- if wav.dtype != np.float32:
45
- if np.issubdtype(wav.dtype, np.integer):
46
- wav = wav.astype("float32") / 32768.0
47
- else:
48
- wav = wav.astype("float32")
49
-
50
- if wav.ndim > 1:
51
- wav = wav.mean(axis=1)
52
-
53
  return wav, sr
54
  except Exception:
55
  return None, None
 
6
 
7
  def install_dependencies():
8
  commands = [
9
+ "pip install spaces-0.1.0-py3-none-any.whl",
10
+ "pip install librosa"
11
  ]
12
  for cmd in commands:
13
  os.system(cmd)
 
19
  import soundfile as sf
20
  import torch
21
  import gradio as gr
22
+ import librosa
23
  from huggingface_hub import snapshot_download
24
 
25
  try:
 
42
 
43
  def load_audio_for_model(audio_filepath):
44
  try:
45
+ wav, sr = librosa.load(audio_filepath, sr=16000)
 
 
 
 
 
 
 
 
 
46
  return wav, sr
47
  except Exception:
48
  return None, None