TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

Status
Not open for further replies.

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
Yes, I am.
So, you are saying that your usb sound card does not appear in pavucontrol? If that is the case, is the box in the lower right corner set to show “all devices” or “all input devices”?

Have you tried a different usb sound card?
 

mach1man

Member
Joined
Jul 19, 2009
Messages
10
Reaction score
0
I have tried a different USB sound card. Neither card is recognized by TwoToneDetect at all. I only have the option to select pulse in the TwoToneDetect screen when it is running, but the pulse selection does not register any audio from the USB sound card when playing tones into it for testing purposes.

When I launch TwoToneDetect71d, it initially advises me the program is an executable file and asks whether to execute, execute in terminal or cancel. I select the first, launching the program. On my model 2 raspberry pi, I don't receive this advisory warning like on the model 4. Is this potentially an issue which results in the program not starting automatically from boot?

It seems I'm having a few errors. Not sure exactly what to attribute them all to. This is why I was hoping someone had TwoToneDetect running properly on a model 4 raspberry pi which I could use as an image to circumvent my errors which I was running into.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
The pulse option in the TTD window is correct.

Click to the Raspberry Pi drop down, then Sound and Video, then Pulse Audio Volume control. With TTD running go to the Recording Tab and find the source that indicates TwoToneDetect or python. At the right you should find a drop down box where you can choose the usb sound card. It is probably closing the default which is the internal sound card. Once you make the usb choice it will remember it.

I hope I am going on the right track here, please report back whether this fixes it for you or not.

783241577131928526.png
 

mach1man

Member
Joined
Jul 19, 2009
Messages
10
Reaction score
0
I did the above mentioned steps and it now seems to be recognizing my audio from the soundcard. Issue #1 seems to be fixed! Now to only get the program to successfully start upon booting the raspberry pi...

Thanks you for your help!
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
I did the above mentioned steps and it now seems to be recognizing my audio from the soundcard. Issue #1 seems to be fixed! Now to only get the program to successfully start upon booting the raspberry pi...

Thanks you for your help!

Yes, autostart on a pi running Buster GUI has proven to be challenging. Have a read of this post and see if you can adjust the commands to start TTD.


Let me know how it goes and if you need help with parts of it. This runs ttd in a detached screen. It is likely that your pi2 used a similar arrangement.
 

mach1man

Member
Joined
Jul 19, 2009
Messages
10
Reaction score
0
Yes, autostart on a pi running Buster GUI has proven to be challenging. Have a read of this post and see if you can adjust the commands to start TTD.


Let me know how it goes and if you need help with parts of it. This runs ttd in a detached screen. It is likely that your pi2 used a similar arrangement.

I apologize for still having problems with this. Apparently my lack of experience with the raspberry pi system and coding is beginning to show. I added the above file as listed in the thread you included to review for "Why does Darkice hate me?" and I'm still running into issues. Darkice is installed and instructed to run, however when I enter the command "screen -list" in terminal, I receive the advisory message stating "no sockets running".

I checked the launch.log file in the directory and all I see is "Fri 27 Dec 2019 11:59:13 PM CST Sat 28 Dec 2019 12:00:13 AM CST Sat 28 Dec 2019 12:01:02 AM CST" with nothing else listed. I'm not sure why I'm still running into issues with everything not starting. Thank you for your help and patience with me at this point. I apologize for my lack of experience to make this a quicker solved issue.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
Sorry for confusing things, let's start over with these changes:
(I assume that you successfully installed screen.)

Edit the LXDE autostart file: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

At the end, add: @sh /home/pi/TTDcheck.sh

Here is what it should end up looking like:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@sh /home/pi/TTDcheck.sh

Cntrl-X and save

Attached is a file called TTDcheck.txt. Copy that file to your /home/pi directory and rename it to TTDcheck.sh
Attached is a file called startTTD.txt. Copy that file to your /home/pi directory and rename it to startTTD.sh

Make both scripts executable: sudo chmod +x /home/pi/TTDcheck.sh
sudo chmod +x /home/pi/startTTD.sh

Reboot your pi.

To check and see that darkice is running type screen -list at the command prompt.

These assume that you are running the program from the /home/pi/TTD directory and that the command to start the program is ./TwoToneDetect. If these assumptions are not correct, you will need to adjust the paths in the two file appropriately.

I hope this clears things up.

Jim
 

Attachments

  • startTTD.txt
    58 bytes · Views: 17
  • TTDcheck.txt
    189 bytes · Views: 15

mach1man

Member
Joined
Jul 19, 2009
Messages
10
Reaction score
0
Sorry for confusing things, let's start over with these changes:
(I assume that you successfully installed screen.)

Edit the LXDE autostart file: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

At the end, add: @sh /home/pi/TTDcheck.sh

Here is what it should end up looking like:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@sh /home/pi/TTDcheck.sh

Cntrl-X and save

Attached is a file called TTDcheck.txt. Copy that file to your /home/pi directory and rename it to TTDcheck.sh
Attached is a file called startTTD.txt. Copy that file to your /home/pi directory and rename it to startTTD.sh

Make both scripts executable: sudo chmod +x /home/pi/TTDcheck.sh
sudo chmod +x /home/pi/startTTD.sh

Reboot your pi.

To check and see that darkice is running type screen -list at the command prompt.

These assume that you are running the program from the /home/pi/TTD directory and that the command to start the program is ./TwoToneDetect. If these assumptions are not correct, you will need to adjust the paths in the two file appropriately.

I hope this clears things up.

Jim
[/QUOTE

I did the above steps. After opening up a terminal window after rebooting, I saw the following text: "Running at boot python: can't open file '/home/pi/TTD/TwoToneDetect71d.py': [Errno 2] No such file or directory"

I then checked to see if darkice is running by typing "screen -list" and received the response "No Sockets found in /run/screen/S-pi."

Everything is correct with my directly, "home/pi/TTD/TwoToneDetect71d" and I'm not sure why the terminal window indicates no such file or directly as listed above.
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,323
Reaction score
116

Edit your TTDstart.sh script to use /home/pi/TTD/TwoToneDetect71d rather than /home/pi/TTD/TwoToneDetect71d.py

Andy
 

mach1man

Member
Joined
Jul 19, 2009
Messages
10
Reaction score
0
I went into the file to remove the '.py' from the file and found it was not listed there.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
I see the problem now. The last line in the startTTD.sh script needs to read ./TwoToneDetect71d

Or, as Andy indicated above, if you change that line to /home/pi/TTD/TwoToneDetect71d it should also work.
 

jwcarder

Newbie
Premium Subscriber
Joined
Feb 23, 2019
Messages
1
Reaction score
0
I set up my TTD a while back and used Two Tone Finder to help me find my department tones. I am not catching all of them now and would like to use Two Tone Finder again. Does anyone have a download link?
 

JH49

Member
Joined
Jun 22, 2016
Messages
13
Reaction score
2
I'm running TwoToneDetect71d on a Raspberry Pi 3 with Raspian Buster. Audio gets converted to mp3 just fine but not amr. There is no error message in the log file for converting it to amr.

I installed libavcodec-extra58.

Code:
Done recording  Fire 13:02:40 on 01/30/20
376.463414634 2411 1580410960.11
./audio/Fire_2020_01_30_13_02_16.wav
done writing WAV Fire 13:02:40 on 01/30/20
354.951219512 32420 1580410960.39
247.390243902 18640 1580410960.68
done converting to MP3 Fire 13:02:41 on 01/30/20
done converting to AMR Fire 13:02:41 on 01/30/20


0
entry
['Fire', 1580410936.491545]
setting mail server up
set up mail server
starting TLS
done starting TLS
logging in
logged in
MP3 Group Email sent to "email" via smtp.gmail.com on port 587 using STARTTLS Fire Page Received at 13:02:16 on 01/30/20 13:02:44 on 01/30/20
Traceback (most recent call last):
File "/home/pi/TTD/TwoToneDetect71d.py", line 1300, in mail
IOError: [Errno 2] No such file or directory: './audio/Fire_2020_01_30_13_02_16.amr'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 1 trying again in five seconds for Fire Page Received at 13:02:16 on 01/30/20
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,323
Reaction score
116
I'm running TwoToneDetect71d on a Raspberry Pi 3 with Raspian Buster. Audio gets converted to mp3 just fine but not amr. There is no error message in the log file for converting it to amr.

I installed libavcodec-extra58.

Code:
Done recording  Fire 13:02:40 on 01/30/20
376.463414634 2411 1580410960.11
./audio/Fire_2020_01_30_13_02_16.wav
done writing WAV Fire 13:02:40 on 01/30/20
354.951219512 32420 1580410960.39
247.390243902 18640 1580410960.68
done converting to MP3 Fire 13:02:41 on 01/30/20
done converting to AMR Fire 13:02:41 on 01/30/20


0
entry
['Fire', 1580410936.491545]
setting mail server up
set up mail server
starting TLS
done starting TLS
logging in
logged in
MP3 Group Email sent to "email" via smtp.gmail.com on port 587 using STARTTLS Fire Page Received at 13:02:16 on 01/30/20 13:02:44 on 01/30/20
Traceback (most recent call last):
File "/home/pi/TTD/TwoToneDetect71d.py", line 1300, in mail
IOError: [Errno 2] No such file or directory: './audio/Fire_2020_01_30_13_02_16.amr'
Email not sent via smtp.gmail.com on port 587 using STARTTLS on attempt 1 trying again in five seconds for Fire Page Received at 13:02:16 on 01/30/20
Yeah it appears that the latest version of Buster uses a build of ffmpeg that doesn't include AMR support. You can build ffmpeg from source yourself with AMR and MP3 support as follows:

Code:
cd ~
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg;
sudo apt-get install libopencore-amrnb-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libfdk-aac-dev
./configure --pkg-config-flags=--static --bindir=/home/pi/bin --enable-gpl --enable-libass --enable-nonfree --enable-libmp3lame --enable-libopencore-amrnb --enable-version3 --enable-libfdk-aac
make
sudo make install

Andy
 

JH49

Member
Joined
Jun 22, 2016
Messages
13
Reaction score
2
Yeah it appears that the latest version of Buster uses a build of ffmpeg that doesn't include AMR support. You can build ffmpeg from source yourself with AMR and MP3 support as follows:

Code:
cd ~
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg;
sudo apt-get install libopencore-amrnb-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libfdk-aac-dev
./configure --pkg-config-flags=--static --bindir=/home/pi/bin --enable-gpl --enable-libass --enable-nonfree --enable-libmp3lame --enable-libopencore-amrnb --enable-version3 --enable-libfdk-aac
make
sudo make install

Andy

Thanks Andy!

I'm getting a 'Unable to locate package libfaac-dev' error. Do I need to build it as well?

I must say, Raspian Buster has been nothing but a pain for me compared to Stretch.
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,323
Reaction score
116
Thanks Andy!

I'm getting a 'Unable to locate package libfaac-dev' error. Do I need to build it as well?

I must say, Raspian Buster has been nothing but a pain for me compared to Stretch.
Uh, not sure. Try sudo apt-get install libfaac-dev and then retry from ./configure on down and see what happens?
 

lauralu1212

Newbie
Joined
Oct 5, 2015
Messages
1
Reaction score
0
The initial link is not working, which I get (it was 2013). Has anyone made a how-to recently? I am just newer to linux
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
Try


I would also recommend that you install the Stretch OS on the pi rather than Buster if you can.
 

MDM38

Member
Joined
Oct 23, 2011
Messages
22
Reaction score
3
I am having difficulty getting automatic start to work correctly.

I am currently running TwoToneDetect68 on a RPi 3 model B. I am using Raspbian Jessie. I have two instances running, known as TTD and TTD_B. (I have tried to use TTD72 on Buster, but ran into issues with it crashing every few days and not being able to get it to autostart, it was unreliable, so I went back to my reliable version 68 setup.)

The program will automatically start in two separate detached screen instances, however I receive an error when a tone set is detected. It seems that is only writing a WAV file and not an MP3 or that it can't find the audio folder to save the MP3 to.

When I start TTD from terminal on my gui it runs and works correctly. It has no problem saving the mp3 and sending the email out, I included an example below.

I read through the thread and found similar issues that seemed to be related to ffmpeg, but I don't think that is the issue, since it works fine if I manually start the program in terminal, it is only an issue in the detached screen.

I have posted the error and my scripts below.

Any ideas?


The error

Freq: 304.01 Level: 1880.269865
Waiting for Silence PFD 1st Alarm 12:12:11 on 04/24/20
Done recording PFD 1st Alarm 12:12:13 on 04/24/20
done writing WAV PFD 1st Alarm 12:12:14 on 04/24/20
Traceback (most recent call last):
File "TwoToneDetect68Pi.py", line 886, in alert
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
OSError: [Errno 2] No such file or directory
Traceback (most recent call last):
File "TwoToneDetect68Pi.py", line 542, in mail
IOError: [Errno 2] No such file or directory: './audio/PFD_1st_Alarm_2020_04_24_12_11_40.mp3'
Email not sent on attempt 1trying again in five seconds for PFD 1st Alarm page received at 12:11:40 on 04/24/20
Traceback (most recent call last):
File "TwoToneDetect68Pi.py", line 542, in mail
IOError: [Errno 2] No such file or directory: './audio/PFD_1st_Alarm_2020_04_24_12_11_40.mp3'
Email not sent on attempt 2trying again in five seconds for PFD 1st Alarm page received at 12:11:40 on 04/24/20
Traceback (most recent call last):
File "TwoToneDetect68Pi.py", line 542, in mail
IOError: [Errno 2] No such file or directory: './audio/PFD_1st_Alarm_2020_04_24_12_11_40.mp3'
Email not sent on attempt 3trying again in five seconds for PFD 1st Alarm page received at 12:11:40 on 04/24/20
max retries exceeded, failed to send email







My script for TTDcheck.sh

#!/bin/bash
ps auxw | grep TwoToneDetect | grep -v grep |grep -v SCREEN >> /dev/null
if [ $? != 0 ]
then
date >> launch.log
cd /home/pi/TTD
screen -dmS ttd-screen ./startTTD.sh & > /dev/null
/bin/sleep 5
cd /home/pi/TTD_B
screen -dmS ttd_B-screen ./startTTD_B.sh & > /dev/null

fi



My script for startTTD.sh

#!/bin/bash
cd /home/pi/TTD/
/bin/sleep 3
PULSE_SOURCE=alsa_input.usb-0d8c_C-Media_USB_Audio_Device-00-Device.analog-mono python TwoToneDetect68Pi.pyc





My script for startTTD_B.sh

#!/bin/bash
cd /home/pi/TTD_B/
/bin/sleep 3
PULSE_SOURCE=alsa_input.usb-0d8c_C-Media_USB_Audio_Device-00-Device_1.analog-mono python TwoToneDetect68Pi.pyc






Output when run in terminal on gui

Freq: 482.78 Level: 1775.46971978
Waiting for Silence PFD 1st Alarm 12:17:46 on 04/24/20
Done recording PFD 1st Alarm 12:17:48 on 04/24/20
done writing WAV PFD 1st Alarm 12:17:48 on 04/24/20
ffmpeg version git-2015-12-04-325b593 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --enable-gpl --enable-nonfree --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-postproc --enable-swscale --enable-pthreads --enable-libdc1394 --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 20.100 / 6. 20.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from './audio/PFD_1st_Alarm_2020_04_24_12_17_15.wav':
Duration: 00:00:30.65, bitrate: 176 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, 1 channels, s16, 176 kb/s
Output #0, mp3, to './audio/PFD_1st_Alarm_2020_04_24_12_17_15.mp3':
Metadata:
TSSE : Lavf57.19.100
Stream #0:0: Audio: mp3 (libmp3lame), 11025 Hz, mono, s16p, 128 kb/s
Metadata:
encoder : Lavc57.16.101 libmp3lame
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
size= 241kB time=00:00:30.67 bitrate= 64.4kbits/s
video:0kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.357466%
done converting to MP3 PFD 1st Alarm 12:17:49 on 04/24/20
ffmpeg version git-2015-12-04-325b593 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.2 (Raspbian 4.9.2-10)
configuration: --enable-gpl --enable-nonfree --enable-libgsm --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-postproc --enable-swscale --enable-pthreads --enable-libdc1394 --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb
libavutil 55. 9.100 / 55. 9.100
libavcodec 57. 16.101 / 57. 16.101
libavformat 57. 19.100 / 57. 19.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 20.100 / 6. 20.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from './audio/PFD_1st_Alarm_2020_04_24_12_17_15.wav':
Duration: 00:00:30.65, bitrate: 176 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, 1 channels, s16, 176 kb/s
Output #0, amr, to './audio/PFD_1st_Alarm_2020_04_24_12_17_15.amr':
Metadata:
encoder : Lavf57.19.100
Stream #0:0: Audio: amr_nb (libopencore_amrnb), 8000 Hz, mono, s16, 10 kb/s
Metadata:
encoder : Lavc57.16.101 libopencore_amrnb
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> amr_nb (libopencore_amrnb))
Press [q] to stop, [?] for help
size= 40kB time=00:00:30.65 bitrate= 10.8kbits/s
video:0kB audio:40kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.014496%
done converting to AMR PFD 1st Alarm 12:17:50 on 04/24/20
MP3 Email sent! PFD 1st Alarm page received at 12:17:15 on 04/24/20 12:17:53 12:17:53 on 04/24/20
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,634
Reaction score
177
Location
Massachusetts
When you “ start TTD from terminal on my gui” what exact command are you using? Your error message is showing that when TTD tries to email the attachment that it can’t find the .mp3 file. Usually thus means that ffmpeg isn’t creating it properly.

Does your TTD_B/audio folder contain ANY files?
 
Status
Not open for further replies.
Top