I am attempting to have tones played at the station.
Currently we have the radio playing at the station fairly quietly. If one is working and not listening we may miss the tone and only find it via receiving an e-mail/SMS.
I have setup a relay with a few alarms on it via an optoisolator relay board, that's working well (we have a simple bash script controlling the GPIO pins).
My next step is to have the speakers connected to the output on the PI and turn the volume up and only play our departments tones and not the other dozen departments that shares the frequency.
With this post I am attempting to include enough to be helpful thus it may be overly verbose.
TwoToneDetect is working well for our department. We are running TwoToneDetect on a headless Raspberry PI 3.
We are only running on version of TwoToneDetect and are not running anything else on the Raspberry PI that uses audio.
I am now atteping to get fancy and having and issue if set:
playback_during_record = 1
with
playback_during_record = 0
everything other than the playback is working.
This is the cronjob that I have setup to start everything:
MAILTO=jkates@wvfd.me
@reboot /home/pi/TTD/gpio-reboot.sh
@reboot cd /home/pi/TTD/ && screen -d -m /home/pi/run-TDD.sh
4 4 * * * /usr/bin/find /home/pi/TTD/logfiles -mtime +30 -delete
*/5 * * * * sleep 60; /home/pi/TTD/check-ttd-running.sh
This is our startup script:
#!/bin/sh
export PULSE_SOURCE=alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono
export PULSE_SINK=alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
pacmd "set-default-source alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono"
pacmd "set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo"
cd /home/pi/TTD/
echo ./TwoToneDetect70
cd /home/pi/TTD/ && ./TwoToneDetect70
(I have attmmpted this with alsa_output.platform-soc_audio.analog-stereo as a SINK with the same retuls).
This is the list of Audio Sinks:
pi@comms:~ $ pacmd list-sinks | grep -e 'name:' -e 'index'
* index: 0
name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo>
index: 1
name: <alsa_output.platform-soc_audio.analog-stereo>
I have also attempted the sam with the PULSE_SOURCE and PULSE_SINK not set.
This is the log file from my current test:
default selected as audio input device
default selected as audio output device
Successfully retrieved local tone info at 21:19:31 on 06/11/18
Successfully retrieved local tone info at 21:19:31 on 06/11/18
Tone1
Successfully retrieved local tone info at 21:19:31 on 06/11/18
483.0 12.3977969933
301.0 30.667419789
295.0 48.2842051431
274.0 347.784843007
462.0 167.093593385
285.0 122.271059819
247.0 230.1690025
263.0 142.706550656
263.0 37.3141119503
247.0 123.783107573
263.0 163.265464985
328.0 58.9881886626
247.0 110.92088044
268.0 46.7055115589
268.0 456.531346515
344.0 48.9900321807
387.0 20.2267842258
247.0 12.553876019
301.0 16659.4462412
349.0 8838.25114444
1629.0 17928.7762242
1629.0 14403.2066596
263.0 17.2065772147
1629.0 2329.54005576
1629.0 8531.12017556
322.0 23.0208128322
1597.0 7912.40192502
1597.0 8089.62876176
1597.0 8185.08879493
1597.0 8250.13844091
1597.0 8216.25555016
704.0 17090.6969335
704.0 17140.8904987
704.0 17327.7904244
704.0 18236.7727301
709.0 18120.8059701
704.0 18323.9399207
704.0 18149.3543773
704.0 18386.7731098
709.0 18187.8939825
704.0 18200.29209
704.0 18957.0372221
704.0 18921.3736168
709.0 18817.6042038
704.0 19113.4462887
704.0 19255.2548571
Westport VFD Tone Set Found
0
after record
delay timer Westport VFD 21:22:40 on 06/11/18
0
delay done Westport VFD 21:22:40 on 06/11/18
waiting for audio Westport VFD 21:22:40 on 06/11/18
threshold value: 45
mono
704.0 19223.2374244
threshold exceeded
recording audio Westport VFD 21:22:40 on 06/11/18
iterations: 300
Traceback (most recent call last):
File "TwoToneDetect70.py", line 716, in alert
File "dist-packages/pyaudio.py", line 577, in write
IOError: [Errno Not output stream] -9974
709.0 19152.9878521
478.0 317.280926163
838.0 288.70974401
478.0 268.569162197
478.0 259.876890725
478.0 323.417454983
360.0 285.082441199
838.0 317.516349891
602.0 240.048870877
478.0 287.940957971
done converting to MP3 Westport VFD 21:22:42 on 06/11/18
478.0 269.195501227
478.0 309.703138144
478.0 254.264958375
done converting to AMR Westport VFD 21:22:42 on 06/11/18
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 1 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
311.0 563.206201656
360.0 410.888617805
360.0 349.740494429
602.0 3019.49864986
360.0 807.671106292
360.0 1000.83577943
360.0 708.376258953
360.0 1451.70899051
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 2 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 3 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
max retries exceeded, failed to send email
Traceback (most recent call last):
File "TwoToneDetect70.py", line 976, in alert
OSError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.wav'
This is my tones.cfg for when it failed:
[Tone1]
Atone = 1598.0 ;A tone frequency in Hz
Btone = 707.3 ;B tone frequency in Hz
Btonelength = 3
Description = Westport VFD
Atonelength = 1
gaplength = 0
ignore_after = 5
playback_during_record = 1
email_body = [d] Page Received at [t]
email_subject = [d] Page Received at [t]
mp3_emails ="Jason A Kates"<jason@kates.org>
text_email_send = after record
alert_command = /home/pi/TTD/alert.sh
This is a copy of our config.cfg (usernames & password have been removed):
[Section1]
email_user =
email_pwd =
email_server = smtp.gmail.com ;SMTP server address of email provider
email_port = 587 ;port to access email server with
record_seconds = 30.0 ;number of seconds of audio to record after a valid tone set is found
record_delay = 6 ;number of seconds to wait after a tone set is found before starting to record
tone_tolerance = 0.020 ;tolerance of tone detection algorithm 1% = .01
input_device_index = 5 ;index of audio input device
;output_device_index = 1 ;index of audio output device
output_device_index = 0 ;index of audio output device
audio_threshold = 45 ;threshold of audio squelch. audio signals below this level will be ignored
tone_offset = 0.0 ;tone offset in percentage. .01 = +1% tone offset, -.02 = -2% tone offset, etc.
mp3_bitrate = 32000 ;bit rate of mp3 encoder. Lower bitrate = smaller file size and lower audio quality
BCC = 1 ;1 = email addresses will be BCCed (hidden from other recipients). 0 = recipients will see other recipients
email_priority = 1 ;priority of email (1=highest, 3=normal, 5=lowest)
release_time=3.0 ;amount of silence (in seconds) required before recording will stop (max=60 seconds)
audio_channel = mono
email_from =
update_interval = 60.0
stacked_extend_record = 1
email_security = STARTTLS
email_authentication = 1
start_minimized = 0
email_send_sequential = none
upload_ftp_server =
upload_ftp_port = 21
upload_ftp_username =
upload_ftp_password =
upload_file_prefix =
I can play audio and it will change output device depening on what I set for the PULSE_SINK
pi@comms:~ $ aplay police_s.wav
Playing WAVE 'police_s.wav' : Unsigned 8 bit, Rate 22000 Hz, Mono
Allong with it failing to create the .wav file audio never is played on the speakers.
This is the log with: playback_during_record = 0, set:
default selected as audio input device
default selected as audio output device
Successfully retrieved local tone info at 22:01:02 on 06/11/18
Successfully retrieved local tone info at 22:01:02 on 06/11/18
Tone1
Successfully retrieved local tone info at 22:01:02 on 06/11/18
1597.0 27391.8141924
1597.0 27402.4910385
1597.0 27401.1459138
1597.0 27405.9139557
1597.0 27383.2889804
1597.0 27364.7665974
709.0 27216.8052765
709.0 27139.8090436
709.0 27167.2788237
709.0 27096.233312
709.0 27252.2931249
709.0 27297.1757151
709.0 27249.2980383
704.0 27027.253084
704.0 27162.2789564
704.0 27000.1362662
704.0 27223.340621
704.0 27224.1758884
704.0 27129.2798324
704.0 27209.5633407
704.0 27038.1475462
Westport VFD Tone Set Found
0
after record
delay timer Westport VFD 22:02:24 on 06/11/18
0
delay done Westport VFD 22:02:24 on 06/11/18
waiting for audio Westport VFD 22:02:24 on 06/11/18
threshold value: 45
mono
704.0 27313.8014084
360.0 943.707968564
threshold exceeded
recording audio Westport VFD 22:02:24 on 06/11/18
iterations: 300
360.0 789.234650798
360.0 948.968008096
301.0 908.928059418
301.0 865.250809126
360.0 1005.07273568
354.0 4280.65263944
333.0 2529.39100123
467.0 18664.9316649
2457.0 3171.61107288
457.0 4991.20857079
527.0 14493.582017
586.0 8169.20868952
295.0 924.72352407
440.0 3019.14608772
333.0 2522.38104099
586.0 13681.5556649
301.0 1307.42330816
306.0 5208.6127886
2522.0 9654.43646619
2328.0 7319.00927395
2489.0 3505.47267643
295.0 1030.98603669
301.0 9974.907171
360.0 1219.23237371
Waiting for Silence Westport VFD 22:02:52 on 06/11/18
Done recording Westport VFD 22:02:54 on 06/11/18
done writing WAV Westport VFD 22:02:54 on 06/11/18
done converting to MP3 Westport VFD 22:02:56 on 06/11/18
done converting to AMR Westport VFD 22:02:57 on 06/11/18
setting mail server up
set up mail server
starting TLS
done starting TLS
logging in
logged in
MP3 Group Email sent to "Jason A Kates"<jason@kates.org> via smtp.gmail.com on port 587 using STARTTLS Westport VFD Page Received at 22:02:24 on 06/11/18 22:02:59 on 06/11/18
Thanks in advance -Jason
Currently we have the radio playing at the station fairly quietly. If one is working and not listening we may miss the tone and only find it via receiving an e-mail/SMS.
I have setup a relay with a few alarms on it via an optoisolator relay board, that's working well (we have a simple bash script controlling the GPIO pins).
My next step is to have the speakers connected to the output on the PI and turn the volume up and only play our departments tones and not the other dozen departments that shares the frequency.
With this post I am attempting to include enough to be helpful thus it may be overly verbose.
TwoToneDetect is working well for our department. We are running TwoToneDetect on a headless Raspberry PI 3.
We are only running on version of TwoToneDetect and are not running anything else on the Raspberry PI that uses audio.
I am now atteping to get fancy and having and issue if set:
playback_during_record = 1
with
playback_during_record = 0
everything other than the playback is working.
This is the cronjob that I have setup to start everything:
MAILTO=jkates@wvfd.me
@reboot /home/pi/TTD/gpio-reboot.sh
@reboot cd /home/pi/TTD/ && screen -d -m /home/pi/run-TDD.sh
4 4 * * * /usr/bin/find /home/pi/TTD/logfiles -mtime +30 -delete
*/5 * * * * sleep 60; /home/pi/TTD/check-ttd-running.sh
This is our startup script:
#!/bin/sh
export PULSE_SOURCE=alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono
export PULSE_SINK=alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo
pacmd "set-default-source alsa_input.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-mono"
pacmd "set-default-sink alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo"
cd /home/pi/TTD/
echo ./TwoToneDetect70
cd /home/pi/TTD/ && ./TwoToneDetect70
(I have attmmpted this with alsa_output.platform-soc_audio.analog-stereo as a SINK with the same retuls).
This is the list of Audio Sinks:
pi@comms:~ $ pacmd list-sinks | grep -e 'name:' -e 'index'
* index: 0
name: <alsa_output.usb-C-Media_Electronics_Inc._USB_Audio_Device-00.analog-stereo>
index: 1
name: <alsa_output.platform-soc_audio.analog-stereo>
I have also attempted the sam with the PULSE_SOURCE and PULSE_SINK not set.
This is the log file from my current test:
default selected as audio input device
default selected as audio output device
Successfully retrieved local tone info at 21:19:31 on 06/11/18
Successfully retrieved local tone info at 21:19:31 on 06/11/18
Tone1
Successfully retrieved local tone info at 21:19:31 on 06/11/18
483.0 12.3977969933
301.0 30.667419789
295.0 48.2842051431
274.0 347.784843007
462.0 167.093593385
285.0 122.271059819
247.0 230.1690025
263.0 142.706550656
263.0 37.3141119503
247.0 123.783107573
263.0 163.265464985
328.0 58.9881886626
247.0 110.92088044
268.0 46.7055115589
268.0 456.531346515
344.0 48.9900321807
387.0 20.2267842258
247.0 12.553876019
301.0 16659.4462412
349.0 8838.25114444
1629.0 17928.7762242
1629.0 14403.2066596
263.0 17.2065772147
1629.0 2329.54005576
1629.0 8531.12017556
322.0 23.0208128322
1597.0 7912.40192502
1597.0 8089.62876176
1597.0 8185.08879493
1597.0 8250.13844091
1597.0 8216.25555016
704.0 17090.6969335
704.0 17140.8904987
704.0 17327.7904244
704.0 18236.7727301
709.0 18120.8059701
704.0 18323.9399207
704.0 18149.3543773
704.0 18386.7731098
709.0 18187.8939825
704.0 18200.29209
704.0 18957.0372221
704.0 18921.3736168
709.0 18817.6042038
704.0 19113.4462887
704.0 19255.2548571
Westport VFD Tone Set Found
0
after record
delay timer Westport VFD 21:22:40 on 06/11/18
0
delay done Westport VFD 21:22:40 on 06/11/18
waiting for audio Westport VFD 21:22:40 on 06/11/18
threshold value: 45
mono
704.0 19223.2374244
threshold exceeded
recording audio Westport VFD 21:22:40 on 06/11/18
iterations: 300
Traceback (most recent call last):
File "TwoToneDetect70.py", line 716, in alert
File "dist-packages/pyaudio.py", line 577, in write
IOError: [Errno Not output stream] -9974
709.0 19152.9878521
478.0 317.280926163
838.0 288.70974401
478.0 268.569162197
478.0 259.876890725
478.0 323.417454983
360.0 285.082441199
838.0 317.516349891
602.0 240.048870877
478.0 287.940957971
done converting to MP3 Westport VFD 21:22:42 on 06/11/18
478.0 269.195501227
478.0 309.703138144
478.0 254.264958375
done converting to AMR Westport VFD 21:22:42 on 06/11/18
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 1 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
311.0 563.206201656
360.0 410.888617805
360.0 349.740494429
602.0 3019.49864986
360.0 807.671106292
360.0 1000.83577943
360.0 708.376258953
360.0 1451.70899051
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 2 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
Traceback (most recent call last):
File "TTD70.py", line 61, in mail
IOError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.mp3'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 3 trying again in five seconds for Westport VFD Page Received at 21:22:40 on 06/11/18
max retries exceeded, failed to send email
Traceback (most recent call last):
File "TwoToneDetect70.py", line 976, in alert
OSError: [Errno 2] No such file or directory: './audio/Westport_VFD_2018_06_11_21_22_40.wav'
This is my tones.cfg for when it failed:
[Tone1]
Atone = 1598.0 ;A tone frequency in Hz
Btone = 707.3 ;B tone frequency in Hz
Btonelength = 3
Description = Westport VFD
Atonelength = 1
gaplength = 0
ignore_after = 5
playback_during_record = 1
email_body = [d] Page Received at [t]
email_subject = [d] Page Received at [t]
mp3_emails ="Jason A Kates"<jason@kates.org>
text_email_send = after record
alert_command = /home/pi/TTD/alert.sh
This is a copy of our config.cfg (usernames & password have been removed):
[Section1]
email_user =
email_pwd =
email_server = smtp.gmail.com ;SMTP server address of email provider
email_port = 587 ;port to access email server with
record_seconds = 30.0 ;number of seconds of audio to record after a valid tone set is found
record_delay = 6 ;number of seconds to wait after a tone set is found before starting to record
tone_tolerance = 0.020 ;tolerance of tone detection algorithm 1% = .01
input_device_index = 5 ;index of audio input device
;output_device_index = 1 ;index of audio output device
output_device_index = 0 ;index of audio output device
audio_threshold = 45 ;threshold of audio squelch. audio signals below this level will be ignored
tone_offset = 0.0 ;tone offset in percentage. .01 = +1% tone offset, -.02 = -2% tone offset, etc.
mp3_bitrate = 32000 ;bit rate of mp3 encoder. Lower bitrate = smaller file size and lower audio quality
BCC = 1 ;1 = email addresses will be BCCed (hidden from other recipients). 0 = recipients will see other recipients
email_priority = 1 ;priority of email (1=highest, 3=normal, 5=lowest)
release_time=3.0 ;amount of silence (in seconds) required before recording will stop (max=60 seconds)
audio_channel = mono
email_from =
update_interval = 60.0
stacked_extend_record = 1
email_security = STARTTLS
email_authentication = 1
start_minimized = 0
email_send_sequential = none
upload_ftp_server =
upload_ftp_port = 21
upload_ftp_username =
upload_ftp_password =
upload_file_prefix =
I can play audio and it will change output device depening on what I set for the PULSE_SINK
pi@comms:~ $ aplay police_s.wav
Playing WAVE 'police_s.wav' : Unsigned 8 bit, Rate 22000 Hz, Mono
Allong with it failing to create the .wav file audio never is played on the speakers.
This is the log with: playback_during_record = 0, set:
default selected as audio input device
default selected as audio output device
Successfully retrieved local tone info at 22:01:02 on 06/11/18
Successfully retrieved local tone info at 22:01:02 on 06/11/18
Tone1
Successfully retrieved local tone info at 22:01:02 on 06/11/18
1597.0 27391.8141924
1597.0 27402.4910385
1597.0 27401.1459138
1597.0 27405.9139557
1597.0 27383.2889804
1597.0 27364.7665974
709.0 27216.8052765
709.0 27139.8090436
709.0 27167.2788237
709.0 27096.233312
709.0 27252.2931249
709.0 27297.1757151
709.0 27249.2980383
704.0 27027.253084
704.0 27162.2789564
704.0 27000.1362662
704.0 27223.340621
704.0 27224.1758884
704.0 27129.2798324
704.0 27209.5633407
704.0 27038.1475462
Westport VFD Tone Set Found
0
after record
delay timer Westport VFD 22:02:24 on 06/11/18
0
delay done Westport VFD 22:02:24 on 06/11/18
waiting for audio Westport VFD 22:02:24 on 06/11/18
threshold value: 45
mono
704.0 27313.8014084
360.0 943.707968564
threshold exceeded
recording audio Westport VFD 22:02:24 on 06/11/18
iterations: 300
360.0 789.234650798
360.0 948.968008096
301.0 908.928059418
301.0 865.250809126
360.0 1005.07273568
354.0 4280.65263944
333.0 2529.39100123
467.0 18664.9316649
2457.0 3171.61107288
457.0 4991.20857079
527.0 14493.582017
586.0 8169.20868952
295.0 924.72352407
440.0 3019.14608772
333.0 2522.38104099
586.0 13681.5556649
301.0 1307.42330816
306.0 5208.6127886
2522.0 9654.43646619
2328.0 7319.00927395
2489.0 3505.47267643
295.0 1030.98603669
301.0 9974.907171
360.0 1219.23237371
Waiting for Silence Westport VFD 22:02:52 on 06/11/18
Done recording Westport VFD 22:02:54 on 06/11/18
done writing WAV Westport VFD 22:02:54 on 06/11/18
done converting to MP3 Westport VFD 22:02:56 on 06/11/18
done converting to AMR Westport VFD 22:02:57 on 06/11/18
setting mail server up
set up mail server
starting TLS
done starting TLS
logging in
logged in
MP3 Group Email sent to "Jason A Kates"<jason@kates.org> via smtp.gmail.com on port 587 using STARTTLS Westport VFD Page Received at 22:02:24 on 06/11/18 22:02:59 on 06/11/18
Thanks in advance -Jason