emxsys / callattendant

A python-based automated call attendant, call blocker, and voice messaging system running on a Raspberry Pi. Screens callers and block robocalls and scams with a low-cost Raspberry Pi and modem.
https://emxsys.github.io/callattendant/
MIT License
115 stars 37 forks source link

+VSD Silence Detection command not working on Conextant-based modems #116

Closed emxsys closed 3 years ago

emxsys commented 3 years ago

Problem: The modem, after answering a call, does not detect/report the silence after the caller hangs up. Upon investigation, I note the modem accepts, but does not apply, the provided silence detection settings.

Test details: I opened up a terminal session with the modem (using minicom on Linux) and attempted to set a silence detection of 5 seconds in voice mode. The modem accepts the +VSD=128,50 command, but the silence detection remains disabled (0 seconds), as reported by the modem. This can be seen in the following minicom log, annotated with my comments.


Welcome to minicom 2.7.1

OPTIONS: I18n Compiled on Aug 13 2017, 15:25:34. Port /dev/ttyACM0, 13:33:04

Press CTRL-A Z for help on special keys

I entered atz to reset the modem OK

I entered ate1 to echo my commands to the screen OK

at OK

at+vsd? # query silence detection settings before entering voice mode ERROR # returned expected error: not in voice mode

at+fclass=8 # enter voice mode OK

at+vsd? # query silence detection settings 128,0 # returned silence detection disabled: 0 secs OK

at+vsd=? # query silence detection accepted parameter values (0-255),(0-255) OK

at+vsd=128,50 # set silence detection to 5 seconds OK

at+vsd # query silence detection settings 128,0 # silence detection is still disabled. Expected 128,50 OK

J0hnMatrix commented 3 years ago

Hello, Same result here:

Welcome to minicom 2.7.1

OPTIONS: I18n
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyACM0, 14:56:17

Press CTRL-A Z for help on special keys

atz
OK
ate1
OK
at
OK
at+vsd?
ERROR
at+fclass=8
OK
at+vsd?
128,0
OK
at+vsd=?
(0-255),(0-255)

OK
at+vsd128,50
ERROR
at+vsd=128,50
OK
at+vsd?
128,0
OK

Event if you try another numbers, the result is the same:

at+vsd=127,70
OK
at+vsd?
128,0
OK

Maybe a kind of "commit" command needs to be type after the "at+vsd=xxx,xxx" or maybe this command is unsupported as the returned values are 0-255,0-255 for both sds and sdi?

emxsys commented 3 years ago

@J0hnMatrix I'm testing the following block of code in Modem.record_audio. Seems to work in bench tests. Will test and refine on a live phone system.

 # Test for silence on Zoom modems (Conextant). The +VSD doesnt work on these modems.
 if self.model == "ZOOM":
     # Silent frames are made of a mix of \x80 and \x79 bytes, with 90% or more == \x80.
     count = audio_data.count(b'\x80')
     if count >= (CHUNK * 0.90):
         silent_frame_count += 1
     else:
         silent_frame_count = 0
     if silent_frame_count > 40: # 40 frames is ~5 secs
         print(">> Silent frames detected... Stop recording.")
         break