Skip to main content

Draw Images into Spectrograms

Project description

SpectroGraphic

Turn any image into a sound whose spectrogram looks like the image!

result


What is this?

Most sounds are intricate combinations of many acoustic waves each having different frequencies and intensities. A spectrogram is a way to represent sound by plotting time on the horizontal axis and the frequency spectrum on the vertical axis. Sort of like sheet music on steroids.

What this tool does is, taking an image and simply interpreting it as a spectrogram. Therefore, by generating the corresponding sound, we have embedded our image in a spectrogram.

The game DOOM used a similar technique to hide satanic figures inside its soundtrack. Now everyone can do the same! 😊

Set-up

Get the command-line tool spectrographic via pip by running pip install spectrographic. You can also simply use spectrographic.py from stand-alone\ as a command-line tool directly. Furthermore, make sure you meet all the dependencies inside the requirements.txt. Numpy simpleaudio wavio are crucial.

After installation with pip one simply needs to run spectrographic [...] in the console and with the stand-alone script you have to use python spectrographic.py [...] inside the folder containing spectrographic.py.

You could also simply import the SpectroGraphic class from spectrographic

Command-line tool usage

usage: primify.py [-h] [--image IMAGE_PATH] [--max_digits MAX_DIGITS]
                  [--method {0,1,2}] [--output_dir OUTPUT_DIR]
                  [--output_file OUTPUT_FILE] [-v]

Command-line tool for converting images to primes

optional arguments:
  -h, --help            show this help message and exit
  --image IMAGE_PATH    Source image to be converted.
  --max_digits MAX_DIGITS
                        Maximal number of digits the prime can have.
  --method {0,1,2}      Method for converting image. Tweak 'till happy
  --output_dir OUTPUT_DIR
                        Directory of the output text file
  --output_file OUTPUT_FILE
                        File name of the text file containing the prime.
  -v                    Verbose output (Recommended!)

Thus, if you have the source image at ./source.png and you want to generate a 10s long sound in the frequency range of 10kHz to 20kHz. You also want to save the resulting .wav-file as sound.wav and also play the resulting sound. Then you need to run:

spectrographic --image ./source.png --min_freq 10000 --max_freq 20000 --duration 10 --save sound.wav --play

or if you are using the stand-alone script:

python spectrographic.py --image ./source.png --min_freq 10000 --max_freq 20000 --duration 10 --save sound.wav --play

Contribute

Bug reports, fixes and additional features are always welcome! Make sure to run the tests with python setup.py test and write your own for new features. Thanks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spectrographic-0.8.7.tar.gz (5.6 MB view details)

Uploaded Source

File details

Details for the file spectrographic-0.8.7.tar.gz.

File metadata

  • Download URL: spectrographic-0.8.7.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for spectrographic-0.8.7.tar.gz
Algorithm Hash digest
SHA256 7bb9b833ec717a861d9ddfb7ee4fa4408e6272ea5bb733676cda9f7ae72da090
MD5 b948b1d787c08c91786bac190267beb8
BLAKE2b-256 ab44ff523b8a6e61d15dc4f5fb12dd762871a44731f057c93cbc16b5c8a12224

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page