Active Topics

 


Reply
Thread Tools
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#1
[Solution in post #6]

Okay, I admit that this is a crazy idea but...

For a one-off application, I want "something" to continuously monitor an audio line-in (mono would do just fine), detect audio over a certain threshold level, record it until it drops back below the threshold, wait for a given period, play it back, go back to monitoring. And I want it to run unattended.

Detecting the threshold should be easy as the input line is squelched, so the level should be at zero (bar the input electronic's own noise) most of the time.

I did an online search and found at least one parrot program for Windows, but not that flexible (you need to press a button to record, it plays back randomly...). Then I had the brilliant idea to harness my spare N900 to do something like that.

My experience with Linux audio programming equals exactly zero. I suppose I could rip Recaller, myDicto or Orecchiette to shreds and learn something in the process, but I thought I'd ask first. Perhaps what I want could be done with a script? It sounds crazy, but having seen what people can do with a simple command line (like streaming video to a PC), my confidence in what Linux can do for someone who knows how to ask has no limits

Last edited by pichlo; 2013-10-02 at 20:58. Reason: Solution found
 

The Following 4 Users Say Thank You to pichlo For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#2
Originally Posted by pichlo View Post
Okay, I admit that this is a crazy idea but...

For a one-off application, I want "something" to continuously monitor an audio line-in (mono would do just fine), detect audio over a certain threshold level, record it until it drops back below the threshold, wait for a given period, play it back, go back to monitoring. And I want it to run unattended.

Detecting the threshold should be easy as the input line is squelched, so the level should be at zero (bar the input electronic's own noise) most of the time.

I did an online search and found at least one parrot program for Windows, but not that flexible (you need to press a button to record, it plays back randomly...). Then I had the brilliant idea to harness my spare N900 to do something like that.

My experience with Linux audio programming equals exactly zero. I suppose I could rip Recaller, myDicto or Orecchiette to shreds and learn something in the process, but I thought I'd ask first. Perhaps what I want could be done with a script? It sounds crazy, but having seen what people can do with a simple command line (like streaming video to a PC), my confidence in what Linux can do for someone who knows how to ask has no limits
Sounds dead easy. If you can detect the start of the event (when something is audible) and the stop of it, a simple script that pulls audio off the device into a temp file, then plays it out is just some ten lines of bash.
 

The Following User Says Thank You to juiceme For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#3
OK, so howto?

When I said the detection should be easy I meant the conditions are well defined. It should be easy for someone who knows how to do it but, as I say, I am a complete noob in software audio processing. Linux or otherwise.

I was even thinking about two daemons, one continuously recording audio in, let's say, one-second chunks, the other one picking up those chunks, analyzing them and deleting if found to contain silence. Definitely a battery - and possibly eMMC - killer but I only want to run it for one day and on a charger. (And stream to a disposable SD card.)

BTW, where did the tag come from?
 

The Following User Says Thank You to pichlo For This Useful Post:
nokiabot's Avatar
Posts: 1,974 | Thanked: 1,834 times | Joined on Mar 2013 @ india
#4
Crazy idea i want this !
 

The Following User Says Thank You to nokiabot For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#5
Originally Posted by pichlo View Post
I was even thinking about two daemons, one continuously recording audio in, let's say, one-second chunks, the other one picking up those chunks, analyzing them and deleting if found to contain silence. Definitely a battery - and possibly eMMC - killer but I only want to run it for one day and on a charger. (And stream to a disposable SD card.)
That dould work, yes, but I guess there should be a simpler way to detect when sound is present.
Unfortunately I do not know that much about N900 so I cannot give exact advice on how to do it.
 

The Following User Says Thank You to juiceme For This Useful Post:
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#6
For those of you still curious, here's my solution. Not exactly as I would ideally like but good enough for my purposes.

An extensive search on this forum yielded this post about recording and playing back audio from the command line. Easy as pie. The next step was to sort out the triggers. I have not yet figured out how to catch the end of the event and would appreciate any input on that. For the time being, I am using a timer which is good enough for my purposes. But how to trigger the start?

It turned out I had the right tool with me all this time: VU Meter! This nifty utility can run a command at a predefined threshold volume. The rest was to write a simple script and configure VU Meter.

The only problem was that VU Meter executed the script every time the threshold was exceeded, even if a previous instance was already running. So I had to take care of that. Oh, and I had to configure tracker to ignore the target directory. The same effect could be achieved by using a different directory but I wanted the target under MyDocs, to make sure I have enough space and to be available in mass storage mode.

Without further ado, here is my magic script:
Code:
#!/bin/bash

# A simple script to record some sound, wait a bit
# and play it back. Like a talking parrot.
# Takes two command-line parameters:
# $1 ... how long to record
# $2 ... how long to wait before playback

# Work out the file name based on current date/time
fpath=/home/user/MyDocs/.sounds/Recordings
fflag=$fpath/Parrot-in-use
fname=$fpath/Parrot-`date +%Y%m%d-%H%M%S`.raw

# Prevent multiple parallel instances
if [ -e "$fflag" ] ; then
    exit 0
fi
touch $fflag

# Display notification banner
banner()
{
  o=org
  f=freedesktop
  n=Notifications
  dbus-send --type=method_call --dest=$o.$f.$n \
    /$o/$f/$n $o.$f.$n.SystemNoteInfoprint \
    string:"Parrot $1..."
}

# Record...
banner "recording"
parec $fname &
sleep $1
killall parec

# ...wait a bit...
banner "waiting"
sleep $2

# ...and play it back
banner "playing"
pacat $fname

rm $fflag
 

The Following 11 Users Say Thank You to pichlo For This Useful Post:
Posts: 19 | Thanked: 24 times | Joined on May 2014
#7
Out of plain curiosity - what are you using that for? Kids?

I was wondering about variant that would say the thing you've just said in N900's own voide (espeak). But, it would require pocketsphinx to make it understand, and as Saera proved, it's not working ideally.
 
pichlo's Avatar
Posts: 6,445 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#8
Originally Posted by bla1 View Post
Out of plain curiosity - what are you using that for?
Thanks for reminding me about this. I originally wanted it to implement a sort-of radio repeater. Hook up a computer - or, in this case an N900 - to a two-way radio. The radio's earphone output to the mic input and vice-versa. Imagine Anna and Elsa want to talk through two-way radios but are just out of range from each other. Put a repeater somewhere in the middle. When Anna talks, Elsa can't hear her, but the repeater can. It will record Anna's message and then play it back, so Elsa can hear (and so can Anna, which may feel a bit strange but may also be a useful feedback about the connection quality).

In fact the connection quality test was my primary reason for wanting this in the first place Unfortunately other things got in the way and I could not proceed to the implementation for a while and then I forgot about it altogether. Now you've reminded me, I pretty much have to
 

The Following 3 Users Say Thank You to pichlo For This Useful Post:
backcover_press_service's Avatar
Posts: 25 | Thanked: 59 times | Joined on Jun 2014 @ Poland
#9
Absolutely awesome and hilarious, in positive way. If I stumble upon talking N900's in some mountain path or forest late at night, I'll know what it is, at last
__________________
(Much) Nicer version of Shodan...

Be sure to check Open Hardware backcover/body replacement gitorious page!
https://gitorious.org/fremantle-backcover-replacement
 
Posts: 445 | Thanked: 367 times | Joined on Nov 2010 @ Italy
#10
i know some people doing it with Python

https://github.com/zioproto/pyparrot

they use a vhf radio with a Cubieboard

there is a video in this italian blog post http://zioproto.ninux.org/wordpress/...-e-cubieboard/
__________________
Flickr photos taken with N900 https://www.flickr.com/cameras/nokia/n900/
"Closed source software tells you what you can do. With open source, you decide what software can do for you" Richard Stallman
 

The Following 2 Users Say Thank You to gianko For This Useful Post:
Reply

Tags
kill me now, nokia n900, parrot


 
Forum Jump


All times are GMT. The time now is 14:39.