Update app.py
Browse files
app.py
CHANGED
@@ -17,9 +17,11 @@ def query(api_url, payload):
|
|
17 |
|
18 |
# Define the function to translate speech
|
19 |
def translate_speech(audio):
|
|
|
|
|
20 |
# audio is a tuple (np.ndarray, int), we need to save it as a file
|
21 |
audio_data, sample_rate = audio
|
22 |
-
if len(audio_data.shape) == 1: # if audio_data is 1D, reshape it to 2D
|
23 |
audio_data = np.reshape(audio_data, (-1, 1))
|
24 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
25 |
sf.write(f, audio_data, sample_rate)
|
|
|
17 |
|
18 |
# Define the function to translate speech
|
19 |
def translate_speech(audio):
|
20 |
+
print(f"Type of audio: {type(audio)}, Value of audio: {audio}") # Debug line
|
21 |
+
|
22 |
# audio is a tuple (np.ndarray, int), we need to save it as a file
|
23 |
audio_data, sample_rate = audio
|
24 |
+
if isinstance(audio_data, np.ndarray) and len(audio_data.shape) == 1: # if audio_data is 1D, reshape it to 2D
|
25 |
audio_data = np.reshape(audio_data, (-1, 1))
|
26 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
27 |
sf.write(f, audio_data, sample_rate)
|