Spectrogram Text Art¶
Synthesise audio that displays readable text when viewed as a spectrogram.
The function rasterises text with a built-in 5 × 7 bitmap font. Each bitmap column becomes a time slice; each “on” pixel becomes a sine wave at the corresponding frequency between freq_lo and freq_hi. A 3 ms raised-cosine crossfade suppresses clicks at column boundaries. The output is normalised to 0.9 peak amplitude.
- pyminidsp.spectrogram_text(text, freq_lo=200.0, freq_hi=7500.0, duration_sec=2.0, sample_rate=16000.0)[source]¶
Synthesise audio that displays readable text in a spectrogram.
- Parameters:
text – ASCII string to render.
freq_lo – Lowest frequency in Hz.
freq_hi – Highest frequency in Hz.
duration_sec – Total duration in seconds.
sample_rate – Sample rate in Hz.
text – Printable ASCII string to render (must be non-empty).
freq_lo – Lowest frequency in Hz (bottom of text).
freq_hi – Highest frequency in Hz (top of text, must be < Nyquist).
duration_sec – Total duration in seconds.
sample_rate – Sample rate in Hz.
- Returns:
numpy array of audio samples.
- Returns:
Array of audio samples.
sig = md.spectrogram_text("HELLO", freq_lo=200.0, freq_hi=7500.0, duration_sec=2.0, sample_rate=16000.0) # View the spectrogram of sig to see "HELLO" spelled out