Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|