aiXander / Realtime_PyAudio_FFT

Realtime audio analysis in Python, using PyAudio and Numpy to extract and visualize FFT features from streaming audio.
MIT License
955 stars 185 forks source link

Error message on startup #13

Open WinEunuuchs2Unix opened 3 years ago

WinEunuuchs2Unix commented 3 years ago

Super cool program. Congrats.

I'm going to try this with Ubuntu 16.04 (Python 2.7.12) so will have to do a little tweaking.

Tweak #1:

Error message on startup:

~/python/audio$ python run_FFT_analyzer.py

Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 2, in <module>
    from src.stream_analyzer import Stream_Analyzer
ImportError: No module named src.stream_analyzer

To fix this error I used:

~/python/audio$ cd src

~/python/audio/src$ echo "" > __init__.py

TWEAK #2:

I'll be revising this comment from time to time as I run into new issues. For example I will need to add program header stub for UTF-8 encoding due to this new error that popped up after fixing above error:

$ python run_FFT_analyzer.py
Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 58, in <module>
    run_FFT_analyzer()
  File "run_FFT_analyzer.py", line 45, in run_FFT_analyzer
    window_ratio = window_ratio  # Float ratio of the visualizer window. e.g. 24/9
  File "/home/rick/python/audio/src/stream_analyzer.py", line 50, in __init__
    from src.stream_reader_sounddevice import Stream_Reader
  File "/home/rick/python/audio/src/stream_reader_sounddevice.py", line 131
SyntaxError: Non-ASCII character '\xf0' in file /home/rick/python/audio/src/stream_reader_sounddevice.py on line 131, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

This is solved by inserting one line:

# -*- coding: utf-8 -*-

TWEAK #3:

The next error that appears:

$ python run_FFT_analyzer.py
Traceback (most recent call last):
  File "run_FFT_analyzer.py", line 58, in <module>
    run_FFT_analyzer()
  File "run_FFT_analyzer.py", line 45, in run_FFT_analyzer
    window_ratio = window_ratio  # Float ratio of the visualizer window. e.g. 24/9
  File "/home/rick/python/audio/src/stream_analyzer.py", line 50, in __init__
    from src.stream_reader_sounddevice import Stream_Reader
  File "/home/rick/python/audio/src/stream_reader_sounddevice.py", line 5, in <module>
    import sounddevice as sd
ImportError: No module named sounddevice

This is more complicated a fix as described here:

Because the solutions provided use pip or pip3 in Ubuntu which won't work because I only sudo apt install the real solution will be more complicated.