Sifaka_1

The content of the txt message file :

Sifaka_2

Let's create a python script to do an inverse Fourier transform so we obtain the wav audio file back :

import numpy as np
from scipy.io import wavfile

# Read data from file

with open('message.txt', 'r') as f:
    lines = f.readlines()

coefficients = []
max_index = 0
for line in lines:
    index, real, imag = line.strip().split()
    index = int(index)
    real = float(real)
    imag = float(imag)
    coefficients.append((index, real + 1j * imag))
    maxindex = max(max_index, index)

# Determine FFT size (N)

N = max_index + 1

freq_domain = np.zeros(N, dtype=np.complex128)
for idx, coeff in coefficients:
    freqdomain[idx] = coeff

time_domain = np.fft.ifft(freqdomain).real  # Keep real part (audio is real-valued)

# Normalize to prevent clipping

time_domain = timedomain / np.max(np.abs(time_domain))

# Convert to 16-bit PCM format (standard for WAV)

time_domainint16 = (time_domain * 32767).astype(np.int16)

# Save with the original sample rate (48,000 Hz)

wavfile.write('reconstructed.wav', 48000, time_domainint16)

In the reconstructed wav file, we can hear the flag being spelled by an AI voice :

AFZ-logoJeeZy Blog

© 2024-2025 JeeZy Blog