spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
980 stars 145 forks source link

a sounddevice callback swallows all errors #481

Open escolanogui opened 11 months ago

escolanogui commented 11 months ago

Hi, My issue is that just by importing sounddevice, any posterior error in the code is "swallowded", meaning not thrown by the terminal and the terminal just exits without throwing anything.

image

The image above is the closest i could get to having some logs of the error. To get this error i had to import sounddevice inside a function so as to have my code run before because any other way the error was just suppresed.

escolanogui commented 11 months ago

it seems issue #468 has the same problem and might be due to import sounddevice.

HaHeho commented 11 months ago

If the import of sounddevice crashes your Python interpreter, then there may be a problem with the Python environment in which you execute the code. You seem to be on Windows, but please describe how you set up Python and installed the sounddevice package (maybe pip or conda?).

escolanogui commented 11 months ago

This is the info:

pip show sounddevice Name: sounddevice Version: 0.4.6 Summary: Play and Record Sound with Python Home-page: http://python-sounddevice.readthedocs.io/ Author: Matthias Geier Author-email: Matthias.Geier@gmail.com License: MIT Location: c:\users\gescolano\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages Requires: CFFI Required-by:

The problem is that it doesn't crash the python interpreter. After an error occurs, instead of it being thrown to the terminal and stopping execution it just stops executing without giving any feedback. On my other computer with python 3.10 this doesn't happen...

For example:

import sounddevice as sd
stream = sd.InputStream()
stream.start()
print("Recording...")

output: "Recording..."

import torch
vad = torch.hub.load("snakers4/silero-vad", "silero_vad")
print("Recording...")

output: "Recording..."

import sounddevice as sd
import torch
vad = torch.hub.load("snakers4/silero-vad", "silero_vad")
stream = sd.InputStream()
stream.start()
print("Recording...")

output: (nothing). An error must have been thrown, for some reason and the execution just stops with no error thrown.

HaHeho commented 11 months ago

The problem is that it doesn't crash the python interpreter. After an error occurs, instead of it being thrown to the terminal and stopping execution it just stops executing without giving any feedback. On my other computer with python 3.10 this doesn't happen...

This may be an indication that something in the Python environment on the faulty system is broken. You should try setting up a fresh and minimal environment containing only the Python packages you need for the specific project (or testing). I would usually use miniconda for that, but there may be simpler ways if you don't need to always handle different environments.