Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -219,6 +219,10 @@ def detect_voice_activity(audio_file, threshold=0.02):
|
|
| 219 |
# Load the WAV file
|
| 220 |
sample_rate, data = wavfile.read(wav_path)
|
| 221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
# Normalize the audio data
|
| 223 |
if data.dtype != np.float32:
|
| 224 |
data = data.astype(np.float32) / np.iinfo(data.dtype).max
|
|
|
|
| 219 |
# Load the WAV file
|
| 220 |
sample_rate, data = wavfile.read(wav_path)
|
| 221 |
|
| 222 |
+
# If the audio is stereo, convert it to mono by averaging the channels
|
| 223 |
+
if len(data.shape) > 1:
|
| 224 |
+
data = np.mean(data, axis=1)
|
| 225 |
+
|
| 226 |
# Normalize the audio data
|
| 227 |
if data.dtype != np.float32:
|
| 228 |
data = data.astype(np.float32) / np.iinfo(data.dtype).max
|