Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -174,6 +174,7 @@ def validate_api_key(api_key):
|
|
| 174 |
if 'conn' in locals() and conn.is_connected():
|
| 175 |
conn.close()
|
| 176 |
|
|
|
|
| 177 |
def transcribe_audio(audio, sample_rate=None):
|
| 178 |
"""Transcribe audio using Whisper"""
|
| 179 |
try:
|
|
@@ -218,9 +219,9 @@ def transcribe_audio(audio, sample_rate=None):
|
|
| 218 |
print("Converting to numpy array")
|
| 219 |
audio_array = np.array(audio_array, dtype=np.float32)
|
| 220 |
|
| 221 |
-
# Normalize audio if needed -
|
| 222 |
max_val = np.max(np.abs(audio_array))
|
| 223 |
-
if max_val > 1.0:
|
| 224 |
print(f"Normalizing audio values from max {max_val} to [-1.0, 1.0] range")
|
| 225 |
audio_array = audio_array / max_val
|
| 226 |
|
|
|
|
| 174 |
if 'conn' in locals() and conn.is_connected():
|
| 175 |
conn.close()
|
| 176 |
|
| 177 |
+
# Update the transcribe_audio function to fix the numpy array boolean ambiguity error
|
| 178 |
def transcribe_audio(audio, sample_rate=None):
|
| 179 |
"""Transcribe audio using Whisper"""
|
| 180 |
try:
|
|
|
|
| 219 |
print("Converting to numpy array")
|
| 220 |
audio_array = np.array(audio_array, dtype=np.float32)
|
| 221 |
|
| 222 |
+
# Normalize audio if needed - FIX: Don't use the array in a boolean context
|
| 223 |
max_val = np.max(np.abs(audio_array))
|
| 224 |
+
if np.isscalar(max_val) and max_val > 1.0: # Fix: Check if scalar and then compare
|
| 225 |
print(f"Normalizing audio values from max {max_val} to [-1.0, 1.0] range")
|
| 226 |
audio_array = audio_array / max_val
|
| 227 |
|