• Effective immediately we will be deleting, without notice, any negative threads or posts that deal with the use of encryption and streaming of scanner audio.

    We've noticed a huge increase in rants and negative posts that revolve around agencies going to encryption due to the broadcasting of scanner audio on the internet. It's now worn out and continues to be the same recycled rants. These rants hijack the threads and derail the conversation. They no longer have a place anywhere on this forum other than in the designated threads in the Rants forum in the Tavern.

    If you violate these guidelines your post will be deleted without notice and an infraction will be issued. We are not against discussion of this issue. You just need to do it in the right place. For example:
    https://forums.radioreference.com/rants/224104-official-thread-live-audio-feeds-scanners-wait-encryption.html

TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

k1jak

Member
Premium Subscriber
Joined
Sep 22, 2017
Messages
12
Location
Westport Island, ME
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
 
Joined
Aug 27, 2005
Messages
1,099
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
Jason,

I'm trying to remember if I've ever gotten the playback_during_record to work on a Pi or not. The error you're getting is indicating that the system can't access the sound card. The Pyaudio library being used may not support simultaneous playback and record from the same device on a Pi. I would suggest trying to playback through the Pi's onboard audio output (rather than the USB sound card) and see if you can get that to work.

Another more kludgy option would be to route the audio through a relay to the amplifier (assuming you're feeding an amplifier) that's controlled by a GPIO pin.

Andy
 

k1jak

Member
Premium Subscriber
Joined
Sep 22, 2017
Messages
12
Location
Westport Island, ME
Jason,

I'm trying to remember if I've ever gotten the playback_during_record to work on a Pi or not. The error you're getting is indicating that the system can't access the sound card. The Pyaudio library being used may not support simultaneous playback and record from the same device on a Pi. I would suggest trying to playback through the Pi's onboard audio output (rather than the USB sound card) and see if you can get that to work.

Another more kludgy option would be to route the audio through a relay to the amplifier (assuming you're feeding an amplifier) that's controlled by a GPIO pin.

Andy
Andy,
Thanks for the reply.

I have attempted from the on-board audio too, without any luck. Currently the setup is just a bunch of the midland speakers kicking around the station with a 6 way headphones spliter (was setup before my time).

I have purchased one of these: https://smile.amazon.com/gp/product/B00WV7GMA2/ and have the alert code setup to run the 2nd GPIO pin already:

cat TTD/alert.sh
#!/bin/sh
sudo bash -c 'echo "17" > /sys/class/gpio/export' > /dev/null 2>&1
sudo bash -c 'echo "22" > /sys/class/gpio/export' > /dev/null 2>&1
sudo bash -c 'echo "out" > /sys/class/gpio/gpio17/direction'
sudo bash -c 'echo "out" > /sys/class/gpio/gpio22/direction'
# Write output
sudo bash -c 'echo "0" > /sys/class/gpio/gpio17/value'
sudo bash -c 'echo "0" > /sys/class/gpio/gpio22/value'
sleep 3
sudo bash -c 'echo "1" > /sys/class/gpio/gpio17/value'
sleep 90
sudo bash -c 'echo "1" > /sys/class/gpio/gpio22/value'
(It's controlling a two channel relay board for now, thus I may need to reverse the direction of pin 22)
https://smile.amazon.com/gp/product/B00E0NTPP4/

As I am doing this on my own $ i am looking to see if someone will donate an old amplifier to the cause.


-Jason
 
Joined
Aug 29, 2010
Messages
104
Location
Washington County,Vermont
I like the kludgy idea at least as a working proof of concept.
I notice the message free notifications fire off as soon as the tone is received. Perhaps a script similar to how simple pushover fires could work along with that GPIO idea. I have some LEDs driven by TTD and node-red. I will see if they come on early enough to trigger such a speaker relay.

I see this device. Maybe too pricey but looks interesting, often used to control background music when building fire alarms go off:
"st-ssr1 solid state relay"
One of many sources in this link if you can open it.
https://www.bhphotovideo.com/c/prod...Xiz5ZE6yQbrVrU8nxgKx9Tdk6stYDzZxoCaMQQAvD_BwE


Also I kind of recall DC31 saying he could listen to his incoming pages when I was trying to do that. However perhaps it was just the raw scanner feeds we send to broadcastify.

Jason,



I'm trying to remember if I've ever gotten the playback_during_record to work on a Pi or not. The error you're getting is indicating that the system can't access the sound card. The Pyaudio library being used may not support simultaneous playback and record from the same device on a Pi. I would suggest trying to playback through the Pi's onboard audio output (rather than the USB sound card) and see if you can get that to work.



Another more kludgy option would be to route the audio through a relay to the amplifier (assuming you're feeding an amplifier) that's controlled by a GPIO pin.



Andy





Sent from my iPad using Tapatalk
 
Last edited:

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
I like the kludgy idea at least as a working proof of concept.
I notice the message free notifications fire off as soon as the tone is received. Perhaps a script similar to how simple pushover fires could work along with that GPIO idea. I have some LEDs driven by TTD and node-red. I will see if they come on early enough to trigger such a speaker relay.
Also I kind of recall DC31 saying he could listen to his incoming pages when I was trying to do that. However perhaps it was just the raw scanner feeds we send to broadcastify.








Sent from my iPad using Tapatalk
Years ago, i remember having playback_during_record working on a pi. Probably an original Model B pi. In more recent attempts, I have not had success. You can use the alert_command to play a .wav file (alert tone?) which fires as soon as the tone set decodes. Then using the post_emsil_command you could play the recorded dispatch from the audio folder. However, this would delay the message until after recording is completed.

Unless you can get the playback feature working, I think the speaker relay is probably the easiest, cheapest option.

We have a pi connected up (HDMI) to a screen in the apparatus bay displaying IamResponding continuously. Any audio played on that pi comes right out of the tv speakers.
 

k1jak

Member
Premium Subscriber
Joined
Sep 22, 2017
Messages
12
Location
Westport Island, ME
Years ago, i remember having playback_during_record working on a pi. Probably an original Model B pi. In more recent attempts, I have not had success. You can use the alert_command to play a .wav file (alert tone?) which fires as soon as the tone set decodes. Then using the post_emsil_command you could play the recorded dispatch from the audio folder. However, this would delay the message until after recording is completed.

Unless you can get the playback feature working, I think the speaker relay is probably the easiest, cheapest option.

We have a pi connected up (HDMI) to a screen in the apparatus bay displaying IamResponding continuously. Any audio played on that pi comes right out of the tv speakers.
Thanks for the help,

Since I have the relay controlled power strip I have ordered:
https://smile.amazon.com/gp/product/B01FZKA28Y/
https://smile.amazon.com/gp/product/B003DBTAZ4/
https://smile.amazon.com/gp/product/B00081NX5U/

If that works out well I might order a 2nd set and that should give me coverage in all of the bays and upstairs, with better volume only when we need it.

The first set was ~$60 and should arrive Friday. I should be able to install them this weekend and give it a test.

Our station:
https://www.wvfd-me.org/


Thanks again for the the help. This software is very useful for our department.
-Jason
 

nick223

Member
Premium Subscriber
Joined
Jan 10, 2009
Messages
1,000
Location
Ottawa Illinois
Switched to a pi3 setup and the pushover is delayed. It use to be sent instantaneously when ttd detected a tone
on the pi2. Now it’s being delayed 5 mins or more. Any ideas?
 
Joined
Oct 6, 2009
Messages
28
I have been trying to get TTD to work on my new raspberrypi 3. The image from their website doesn't work on rpi3. I am trying to set this up without any GUI.

My only issue right now is I can't get pulseaudio configured correctly. When I run LevelMeter I only get the following options:

AUDIO DEVICE LISTING:
Output Device 0: bcm2835 ALSA: - (hw:0,0)
Output Device 1: bcm2835 ALSA: IEC958/HDMI (hw:0,1)
Input Device 2: USB Sound Device: Audio (hw:1,0)
Output Device 2: USB Sound Device: Audio (hw:1,0)
Output Device 3: sysdefault
Output Device 4: dmix
Input Device 5: default
Output Device 5: default

On my older rpi2 I would get pulse as one of the input/output options.

Anyone have a step by step to properly setting up pulseaudio on the rpi3 for use with TTD?

Also, LevelMeter.py works with source 5. However, if I give source 5 to TTD it will crash with:

Traceback (most recent call last):
File "Fire.py", line 833, in <module>
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, output=False, frames_per_buffer=chunk, input_device_index=input_device, output_device_index=output_device)
NameError: name 'input_device' is not defined
Traceback (most recent call last):
File "Fire.py", line 862, in <module>
audio_data = record(0.2, audio_channel)
File "Fire.py", line 841, in record
data = stream.read(chunk)
NameError: global name 'stream' is not defined
 
Last edited:
Joined
Oct 6, 2009
Messages
28
Forget my prior post. I was using a modified version of 68 that I run. I upgraded to v70 and made the same modifications (removing all emailing/recording features) and it now works on the rpi3.
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
I have been trying to get TTD to work on my new raspberrypi 3. The image from their website doesn't work on rpi3. I am trying to set this up without any GUI.

My only issue right now is I can't get pulseaudio configured correctly. When I run LevelMeter I only get the following options:

AUDIO DEVICE LISTING:
Output Device 0: bcm2835 ALSA: - (hw:0,0)
Output Device 1: bcm2835 ALSA: IEC958/HDMI (hw:0,1)
Input Device 2: USB Sound Device: Audio (hw:1,0)
Output Device 2: USB Sound Device: Audio (hw:1,0)
Output Device 3: sysdefault
Output Device 4: dmix
Input Device 5: default
Output Device 5: default

On my older rpi2 I would get pulse as one of the input/output options.

Anyone have a step by step to properly setting up pulseaudio on the rpi3 for use with TTD?

Also, LevelMeter.py works with source 5. However, if I give source 5 to TTD it will crash with:

Traceback (most recent call last):
File "Fire.py", line 833, in <module>
stream = p.open(format=FORMAT, channels=CHANNELS, rate=RATE, input=True, output=False, frames_per_buffer=chunk, input_device_index=input_device, output_device_index=output_device)
NameError: name 'input_device' is not defined
Traceback (most recent call last):
File "Fire.py", line 862, in <module>
audio_data = record(0.2, audio_channel)
File "Fire.py", line 841, in record
data = stream.read(chunk)
NameError: global name 'stream' is not defined
Try default as the source
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
Try default as the source
Sorry, I should not hsve been so brief.

If you are using TTD in the GUI mode, choose default as the input device in the TTD window.

If you are using TTD in command line mode, set both input and output device indexes in config.cfg to 0 (zero)
 
Joined
Sep 10, 2009
Messages
7
Location
Waldron, Ar
Hello guys I need some help everytime I try to run ttd after modifying the config file it gives me this in the logfiles and wont run ttd


Sent from my SM-G950U using Tapatalk
 
Joined
Sep 10, 2009
Messages
7
Location
Waldron, Ar
Hello guys I need some help everytime I try to run ttd after modifying the config file it gives me this in the logfiles and wont run ttd


Sent from my SM-G950U using Tapatalk
Got it figured out. Forgot to put my password in to base64. Now if I can just get it to start automatically on boot

Sent from my SM-G950U using Tapatalk
 
Joined
Aug 29, 2010
Messages
104
Location
Washington County,Vermont
Fresh TTD70 install, fresh raspian GUI install, pi3:
-----------
Running TTD manually in GUI , ok
Auto start and restart via a new systemd script, ok

-----------
Use raspian-config to turn off GUI so to boot to CLI for CLI testing.... Reboot ....

Auto start via the same new systemd script, led starts flashing on USB audio device but nothing going to logfile. , **NOT ok**
...Stop new service ....
Manually start levelmeter and it works fine, ok
Manually start TTD, ok

Question what is different about command line environment that may impact startup via systemd??

I will share all this once it works!!
Thank you


Sent from my iPad using Tapatalk
 
Joined
Nov 11, 2004
Messages
3
Jim,

If you have a v70 image, I would appreciate getting the link you have. If not, the v60 version still has all the functionality I need.

Thanks,

Jerry
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
What version of the pi are you running? An original model B, a pi2, or a pi3? If you have the original Model B and you are satisfied with it, you may want to stay there as it is pretty bulletproof. You can run the command line version of TTD70 on an old pi. Upgrading to the gui version will have performance issues on the old pi. It runs well on the pi2/3.
 
Joined
Nov 11, 2004
Messages
3
Jim,

I'm running a pi 3. I'd like to run the command line version and have it autostart, but what do you do about the stream of text that comes from that version. Do I log it, ignore it, ?
 
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
Start on Boot

Sorry I tried every option I could find and no luck. I want my RPi 3b+ to boot TTD 70 on boot but it wont work no matter what I try. I am completely new to this. I was able to get the program to execute a script that plays a station tone and activates a strobe in the bunkroom and play audio after the tone. .

I noticed that TTD will not open unless I open and run pulse audio first so I make sure to do that when I SSH in or use a tv/monitor so I added pulse audio in crontab

When I went into the crontab it shows a syntax error Non-ASCII character '\x99' in file /home/pi/TTD/TwoToneDetect70 on line 2, but no encoding declared...

Maybe Im doing it totally wrong, idk...went through a bunch of searches and youtube videos with no luck

So I got frustrated and tried to download the TTD image from the website onto a brand new SD card I bought today and no matter what I do to the SD card (followed instructions from raspberry pi site) its just the rainbow screen.

Any help is appreciated!
 
Last edited:
Top