Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    N900 as a talking parrot

    Reply
    pichlo | # 1 | 2013-09-26, 13:00 | Report

    [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

    Edit | Forward | Quote | Quick Reply | Thanks

    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:
    Ariadeno, bla1, sixwheeledbeast, Wikiwide

     
    juiceme | # 2 | 2013-09-26, 14:03 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to juiceme For This Useful Post:
    Wikiwide

     
    pichlo | # 3 | 2013-09-26, 14:44 | Report

    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?

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to pichlo For This Useful Post:
    Wikiwide

     
    nokiabot | # 4 | 2013-09-26, 16:23 | Report

    Crazy idea i want this !

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to nokiabot For This Useful Post:
    Wikiwide

     
    juiceme | # 5 | 2013-09-26, 19:02 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following User Says Thank You to juiceme For This Useful Post:
    Wikiwide

     
    pichlo | # 6 | 2013-10-02, 20:52 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 11 Users Say Thank You to pichlo For This Useful Post:
    Ariadeno, bla1, chill, dr_frost_dk, handaxe, juiceme, peterleinchen, reinob, rotoflex, Sohil876, Wikiwide

     
    bla1 | # 7 | 2014-06-02, 11:18 | Report

    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.

    Edit | Forward | Quote | Quick Reply | Thanks

     
    pichlo | # 8 | 2014-06-02, 19:49 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 3 Users Say Thank You to pichlo For This Useful Post:
    backcover_press_service, FlashInTheNight86, reinob

     
    backcover_press_service | # 9 | 2014-06-02, 20:26 | Report

    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

    Edit | Forward | Quote | Quick Reply | Thanks

     
    gianko | # 10 | 2014-06-02, 23:57 | Report

    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/

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to gianko For This Useful Post:
    backcover_press_service, pichlo

     
vBulletin® Version 3.8.8
Normal Logout