| import base64 | |
| def encode_audio_to_base64(audio_path): | |
| with open(audio_path, "rb") as f: | |
| return base64.b64encode(f.read()).decode() | |
| def decode_audio_from_base64(encoded_audio, output_path): | |
| audio_data = base64.b64decode(encoded_audio) | |
| with open(output_path, "wb") as f: | |
| f.write(audio_data) | |
| return output_path |