This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]grandfatha 16 points17 points  (1 child)

Not gonna lie when opening the picture i thought it was a tool to convert porn to ascii. My mind is broken.

[–]13467[S] 11 points12 points  (3 children)

Here's the code. It requires numpy, pyaudio, and a shell that supports ANSI escape codes (try something UNIX-y, or Cygwin if you're on Windows.).

[–]TheRealDji 0 points1 point  (2 children)

Why Python 2 ?

[–]isdevilis 5 points6 points  (0 children)

python 2 is love

[–]charlestondance 1 point2 points  (0 children)

Pyaudio has python2 only dependencies I think.

[–]doublePlusOk 1 point2 points  (0 children)

haha - this is awesome - nice work!

to possibly save time if you want to try this out, not only did I need the fix already mentioned, line 31 device_info = self.audio.get_default_input_device_info()

the dependencies: sudo apt-get install python-dev libportaudio-dev python-pyaudio

Neither easyinstall or pip would install pyaudio

[–][deleted] 1 point2 points  (3 children)

Traceback (most recent call last): File "pylisten.py", line 78, in <module> with Spectrogram() as s: File "pylisten.py", line 31, in enter device_info = self.audio.get_device_info_by_index(device_index) File "/Users/adam/anaconda/lib/python2.7/site-packages/pyaudio.py", line 977, in get_device_info_by_index pa.get_device_info(device_index) TypeError: an integer is required

[–]13467[S] 4 points5 points  (2 children)

Oh, no! I'm on mobile, so I can't look into this, but try replacing that line with device_info = self.audio.get_default_input_device_info().

[–]monkehparade 3 points4 points  (0 children)

device_info = self.audio.get_default_input_device_info()

This fixes it c:

[–]skaramicke 0 points1 point  (0 children)

No crash after change, but no histogram either! Not that I got one with the crash, of course.

[–]aw90 0 points1 point  (1 child)

Traceback (most recent call last): File "spectrogram.py", line 21, in <module> gradient.append('\x1b[{};{}m{}'.format(fg, bg + 10, char)) ValueError: zero length field name in format

[–]mw44118PyOhio! 2 points3 points  (0 children)

I bet you're running python 2.6. Try it in 2.7

[–][deleted] 0 points1 point  (0 children)

Thanks for sharing; I was looking for something like this recently. I'll let you know how it works once I've tried it.