• Stars
    star
    260
  • Rank 156,306 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Turn an image into sound whose spectrogram looks like the image.

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. Install them with pip install requirements.txt.

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.base. Check the doc-strings for detailed explanations and more features.

Command-line tool usage

usage: spectrographic [-h] [--version] -i PATH_TO_IMAGE [-d DURATION] [-m MIN_FREQ] [-M MAX_FREQ] [-r RESOLUTION] [-c CONTRAST] [-p] [-s SAVE_FILE]

Turn any image into sound.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -i PATH_TO_IMAGE, --image PATH_TO_IMAGE
                        Path of image that we want to embed in a spectrogram.
  -d DURATION, --duration DURATION
                        Duration of generated sound.
  -m MIN_FREQ, --min_freq MIN_FREQ
                        Smallest frequency used for drawing the image.
  -M MAX_FREQ, --max_freq MAX_FREQ
                        Largest frequency used for drawing the image.
  -r RESOLUTION, --resolution RESOLUTION
                        Vertical resolution of the image in the spectrogram.
  -c CONTRAST, --contrast CONTRAST
                        Contrast of the image in the spectrogram.
  -p, --play            Directly play the resulting sound.
  -s SAVE_FILE, --save SAVE_FILE
                        Path to .wav file in which to save the resulting sound.

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.

More Repositories

1

primify

Embed any image into a prime number.
Python
464
star
2

lancer

Turn your python code into a hideous mess. Ever heard of Black? This is the opposite.
Python
255
star
3

Logation

Analyse your NGINX access logs and create beautiful maps of the locations from which people access your service.
Python
115
star
4

motionblur

Generate authentic motion blur kernels (point spread functions) and apply them to images. Fast and Simple.
Python
105
star
5

non-api-fb-scraper

Scrape public FaceBook posts from any group or user into a .csv file without needing to register for any API access
Python
47
star
6

garnn

TensorFlow implementation of Graphical Attention Recurrent Neural Networks based on work by Cirstea et al., 2019.
Python
27
star
7

dgcnn

Clean & Documented TF2 implementation of "An end-to-end deep learning architecture for graph classification" (M. Zhang et al., 2018).
Python
24
star
8

img2rag

Convert any image into a Region Adjacency Graph (RAG)
Python
12
star
9

StackData

Data set containing the key techologies used by ~1000 top tech companies.
8
star
10

rateyourcircle

Draw a circle and see how close you got to drawing a perfect circle.
JavaScript
7
star
11

gtraceroute

gtraceroute is a sophisticated network diagnostic tool, combining the utility of traditional traceroute with a user-friendly UI similar to PingPlotter.
Python
3
star
12

dortmund2array

Tool to convert datasets from "Benchmark Data Sets for Graph Kernels" (K. Kersting et al., 2016) into a format suitable for deep learning research.
Python
2
star
13

RedditLiveChart

The Back- and Frontend behind my popular /r/dataisbeautiful post.
JavaScript
1
star
14

adadelta_py

Clean & dependency-free implementation of the ADADELTA algorithm in python.
Python
1
star
15

hybrid-face

See one face up close and another from far away!
Python
1
star
16

LinAlg-NumberTheory

Just some maths modules for linear algebra and number theory.
Python
1
star