Spaces:
Runtime error
Runtime error
Kabatubare
commited on
Commit
•
04a53dc
1
Parent(s):
1398c93
Update app.py
Browse files
app.py
CHANGED
@@ -6,12 +6,20 @@ import traceback
|
|
6 |
|
7 |
def detect_watermark(audio_data):
|
8 |
try:
|
9 |
-
#
|
10 |
-
if not isinstance(audio_data, tuple)
|
11 |
-
return f"Invalid input
|
12 |
-
|
|
|
13 |
audio_array, sample_rate = audio_data
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Ensure audio_array is 2D (channels, samples). If it's mono, add an axis.
|
16 |
if audio_array.ndim == 1:
|
17 |
audio_array = np.expand_dims(audio_array, axis=0)
|
|
|
6 |
|
7 |
def detect_watermark(audio_data):
|
8 |
try:
|
9 |
+
# Ensure that audio_data is a tuple with two elements
|
10 |
+
if not (isinstance(audio_data, tuple) and len(audio_data) == 2):
|
11 |
+
return f"Invalid input: expected a tuple with two elements, got {type(audio_data)} with length {len(audio_data)}"
|
12 |
+
|
13 |
+
# Ensure the first element of the tuple is a NumPy array
|
14 |
audio_array, sample_rate = audio_data
|
15 |
+
if not isinstance(audio_array, np.ndarray):
|
16 |
+
return f"Invalid input: expected the first element of the tuple to be a np.ndarray, got {type(audio_array)}"
|
17 |
+
|
18 |
+
# Ensure the second element of the tuple is an integer (sample rate)
|
19 |
+
if not isinstance(sample_rate, int):
|
20 |
+
return f"Invalid input: expected the second element of the tuple to be an int (sample rate), got {type(sample_rate)}"
|
21 |
+
|
22 |
+
# Now we can proceed with the assurance that audio_array is an np.ndarray and sample_rate is an int
|
23 |
# Ensure audio_array is 2D (channels, samples). If it's mono, add an axis.
|
24 |
if audio_array.ndim == 1:
|
25 |
audio_array = np.expand_dims(audio_array, axis=0)
|