I'm trying to use pydub to combine multiple audio files.
When I create a string and then try to exec
that while assigning it to a variable
it doesn't work and the variable returns a 'none' type error when I try to export the audio.
from pydub import AudioSegment
bass = AudioSegment.from_file("bass.ogg")
gtr = AudioSegment.from_file("guitar.ogg")
tracks = "gtr.overlay(bass)"
execTracks = exec(tracks) # I'd like this to work
manualTracks = gtr.overlay(bass) # This works properly
print(execTracks)
print(manualTracks)
output:
None
<pydub.audio_segment.AudioSegment object at 0x100b915e0>
The reason I want to use 'exec' is because the 'tracks' variable will change depending on the files available.
Thank you for any tips or guidance!