Spaces:
Running
Running
UPDATE
Browse files
app.py
CHANGED
@@ -183,31 +183,26 @@ async def audio_effect_handler(event):
|
|
183 |
audio_file = states[user_id]['audio']
|
184 |
|
185 |
query = event.pattern_match.group(1).decode("UTF-8")
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
|
202 |
-
|
203 |
-
|
204 |
|
205 |
-
|
206 |
|
207 |
-
except Fusion.InvalidMusicFileError as e:
|
208 |
-
await event.reply(str(e))
|
209 |
-
except Exception as e:
|
210 |
-
await event.reply(f"An error occurred: {str(e)}")
|
211 |
|
212 |
|
213 |
@client.on(events.CallbackQuery(pattern=b'preview'))
|
@@ -216,7 +211,7 @@ async def preview_handler(event):
|
|
216 |
if user_id in states and states[user_id]:
|
217 |
# Send the current modification for preview
|
218 |
output_file_name = f"{user_id}_preview"
|
219 |
-
output_file = Fusion.saveSound(states[user_id], output_file_name)
|
220 |
await event.edit("`Uploading...`", buttons=buttons)
|
221 |
# Edit the message and send the audio file in the edited message
|
222 |
await event.edit(file=output_file, text="`Preview the current modification:`", buttons=buttons)
|
|
|
183 |
audio_file = states[user_id]['audio']
|
184 |
|
185 |
query = event.pattern_match.group(1).decode("UTF-8")
|
186 |
+
sound = Fusion.from_file(audio_file, format="mp3")
|
187 |
+
if query == 'slowed':
|
188 |
+
modified_sound = Fusion.effectSlowed(sound, 0.9)
|
189 |
+
elif query == 'speedup':
|
190 |
+
modified_sound = Fusion.effectSlowed(sound, 1.1)
|
191 |
+
elif query == '8d':
|
192 |
+
modified_sound = Fusion.effect8D(sound)
|
193 |
+
elif query == 'reverb':
|
194 |
+
modified_sound = Fusion.effectReverb(sound)
|
195 |
+
elif query == 'reverse':
|
196 |
+
modified_sound = sound.reverse()
|
197 |
+
else:
|
198 |
+
return await event.answer("INvalid for now...")
|
199 |
+
|
|
|
200 |
|
201 |
+
# Update the user's state with the modified sound
|
202 |
+
states[user_id]['audio'] = modified_sound
|
203 |
|
204 |
+
await event.answer("Effect applied. Click /send to receive the modified audio file.", alert="True")
|
205 |
|
|
|
|
|
|
|
|
|
206 |
|
207 |
|
208 |
@client.on(events.CallbackQuery(pattern=b'preview'))
|
|
|
211 |
if user_id in states and states[user_id]:
|
212 |
# Send the current modification for preview
|
213 |
output_file_name = f"{user_id}_preview"
|
214 |
+
output_file = Fusion.saveSound(states[user_id]['audio'], output_file_name)
|
215 |
await event.edit("`Uploading...`", buttons=buttons)
|
216 |
# Edit the message and send the audio file in the edited message
|
217 |
await event.edit(file=output_file, text="`Preview the current modification:`", buttons=buttons)
|