chaosparrot / parrot.py

Computer interaction using audio and speechrecognition
MIT License
139 stars 36 forks source link

settings.py errors when trying to record and the audio input is muted. #36

Closed ykuksenko closed 7 months ago

ykuksenko commented 1 year ago

When trying to record a sound using python settings.py the application prints a traceback if the audio input is muted. Unmuting immediately fixes this issue.

It would be good if that was handled with a message suggesting that the interface is muted or there is another issue.

traceback:

----------- ERROR DURING RECORDING -------------- 
Traceback (most recent call last):
  File "/home/user/apps/parrot.py/lib/record_data.py", line 312, in record_consumer
    recorder.add_audio_frame(indexedQueue.get())
  File "/home/user/apps/parrot.py/lib/stream_recorder.py", line 62, in add_audio_frame
    process_audio_frame(self.index, self.audio_frames, self.detection_state, self.detection_frames, self.current_occurrence, self.false_occurrence)
  File "/home/user/apps/parrot.py/lib/stream_processing.py", line 75, in process_audio_frame
    detection_frames.append(determine_detection_frame(index, detection_state, audioFrames))
  File "/home/user/apps/parrot.py/lib/stream_processing.py", line 125, in determine_detection_frame
    dBFS = determine_dBFS( wave_data )
  File "/home/user/apps/parrot.py/lib/signal_processing.py", line 16, in determine_dBFS
    return 20 * math.log10(determine_power(waveData) / math.pow(32767, 2))
ValueError: math domain error
paul-schaaf commented 1 year ago

this happens for me when using my headset even when Im not muted. I changed the function so that if f == 0: f = 0000000001 where f = determine_power(waveData)

chaosparrot commented 1 year ago

I fixed this issue in a different branch, so it should work in the next release