Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -132,15 +132,15 @@ def do_ML(filename:str,text:str):
|
|
132 |
|
133 |
def compress_audio_wav_bytes(wav_bytes, output_format):
|
134 |
# Load the WAV data from bytes
|
135 |
-
|
136 |
|
137 |
# Compress and save the audio data with the specified output format
|
138 |
-
|
139 |
-
|
140 |
|
141 |
# Retrieve the compressed audio data as bytes
|
142 |
-
|
143 |
-
|
144 |
|
145 |
|
146 |
|
|
|
132 |
|
133 |
def compress_audio_wav_bytes(wav_bytes, output_format):
|
134 |
# Load the WAV data from bytes
|
135 |
+
audio_data, sample_rate = sf.read((wav_bytes))
|
136 |
|
137 |
# Compress and save the audio data with the specified output format
|
138 |
+
output_bytes = io.BytesIO()
|
139 |
+
sf.write(output_bytes, audio_data, sample_rate, format=output_format)
|
140 |
|
141 |
# Retrieve the compressed audio data as bytes
|
142 |
+
compressed_bytes = output_bytes.getvalue()
|
143 |
+
return compressed_bytes
|
144 |
|
145 |
|
146 |
|