Here is example code:
import base64
# pick sound file you have in working directory
# or give full path
sound_file = "original.mp3"
# use mode = "rb" to read binary file
fin = open(sound_file, "rb")
binary_data = fin.read()
fin.close()
# encode binary to base64 string (printable)
b64_data = base64.b64encode(binary_data)
b64_fname = "original_b64.txt"
# save base64 string to given text file
fout = open(b64_fname, "w")
fout.write(b64_data)
fout.close
# read base64 string back in
fin = open(b64_fname, "r")
b64_str = fin.read()
fin.close()
# decode base64 string to original binary sound object
mp3_data = base64.b64decode(b64_str)
bumsfeld
Nearly a Posting Virtuoso
1,495 posts since Jul 2005
Reputation Points: 409
Solved Threads: 235
Skill Endorsements: 1