Spaces:
Sleeping

minjune121 commited on
Commit
9a6f6bc
ยท
verified ยท
1 Parent(s): adbf71c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -714,11 +714,16 @@ def process_voice(audio_input, user_id=None):
714
  return json.dumps({"error": "STT ๋ชจ๋ธ์ด ๋กœ๋“œ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."}, ensure_ascii=False, indent=2), []
715
  try:
716
  if isinstance(audio_input, str):
717
- import soundfile as sf
718
- y, sr = sf.read(audio_input)
719
- y = y.astype(np.float32)
720
- if y.ndim > 1:
721
- y = y.mean(axis=1)
 
 
 
 
 
722
  else:
723
  sr, y = audio_input
724
  y = y.astype(np.float32)
 
714
  return json.dumps({"error": "STT ๋ชจ๋ธ์ด ๋กœ๋“œ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค."}, ensure_ascii=False, indent=2), []
715
  try:
716
  if isinstance(audio_input, str):
717
+ try:
718
+ import soundfile as sf
719
+ y, sr = sf.read(audio_input)
720
+ y = y.astype(np.float32)
721
+ if y.ndim > 1:
722
+ y = y.mean(axis=1)
723
+ except Exception:
724
+ import librosa
725
+ y, sr = librosa.load(audio_input, sr=None, mono=True)
726
+ y = y.astype(np.float32)
727
  else:
728
  sr, y = audio_input
729
  y = y.astype(np.float32)