Spaces:
Sleeping
Sleeping
Aboubacar OUATTARA - kaira
commited on
Commit
•
7f2b715
1
Parent(s):
5a6cca7
add audios files
Browse files
app.py
CHANGED
@@ -96,6 +96,15 @@ def enhance_speech(audio_array, sampling_rate, solver, nfe, tau, denoise_before_
|
|
96 |
return (new_sr1, denoised_audio.cpu().numpy()), (new_sr2, enhanced_audio.cpu().numpy())
|
97 |
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
# Define the Gradio interface
|
100 |
def _fn(
|
101 |
src_lang,
|
@@ -130,11 +139,16 @@ def _fn(
|
|
130 |
print("Audio Array Shape:", audio_array.shape)
|
131 |
print("Sample Rate:", sampling_rate)
|
132 |
print("Audio Array Dtype:", audio_array.dtype)
|
133 |
-
print("Max Value in Audio Array:",
|
134 |
-
print("Min Value in Audio Array:",
|
135 |
|
136 |
# Return all outputs
|
137 |
-
return
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
|
140 |
def main():
|
|
|
96 |
return (new_sr1, denoised_audio.cpu().numpy()), (new_sr2, enhanced_audio.cpu().numpy())
|
97 |
|
98 |
|
99 |
+
def convert_to_int16(audio_array):
|
100 |
+
if audio_array.dtype == torch.float32:
|
101 |
+
# Assuming audio_array values are in the range [-1.0, 1.0]
|
102 |
+
# Scale to int16 range and convert the datatype
|
103 |
+
audio_array = (audio_array * 32767).to(torch.int16)
|
104 |
+
|
105 |
+
return audio_array
|
106 |
+
|
107 |
+
|
108 |
# Define the Gradio interface
|
109 |
def _fn(
|
110 |
src_lang,
|
|
|
139 |
print("Audio Array Shape:", audio_array.shape)
|
140 |
print("Sample Rate:", sampling_rate)
|
141 |
print("Audio Array Dtype:", audio_array.dtype)
|
142 |
+
print("Max Value in Audio Array:", torch.max(audio_array))
|
143 |
+
print("Min Value in Audio Array:", torch.min(audio_array))
|
144 |
|
145 |
# Return all outputs
|
146 |
+
return (
|
147 |
+
bambara_text,
|
148 |
+
(sampling_rate, convert_to_int16(audio_array).numpy()),
|
149 |
+
(denoised_audio[0], convert_to_int16(denoised_audio[1])),
|
150 |
+
(enhanced_audio[0], convert_to_int16(enhanced_audio[1]))
|
151 |
+
)
|
152 |
|
153 |
|
154 |
def main():
|