Wednesday, 15 June 2016

Hello, it's Lenny!

Last month, I told you about Lenny, who is a series of recorded files that are played in sequence to telemarketers. I get a couple of telemarketers per day, so I thought I might do a similar thing.

First, I downloaded the Lenny sound files. They're mp3, so I converted them to wav, and gave them file names 01.wav to 16.wav. The Lenny scripts are rather good, I think, there's just enough encouragement for the telemarketer for them to continue their spiel, together with some additional information for them about my eldest daughter Rachel and third eldest daughter Larissa. And the ducks are amazeballs!

I tried setting it all up on a Raspberry Pi, but I ran into a bit of a problem. The thing that interfaces the USB to a mic and speaker, has the holes too close together, so I can't plug both into that, and if I tell the Pi to use it so that the microphone works, the pi wants to use it for the speaker. And the holes are too close together. It's a silly problem, and there's probably a simple solution, but it'll need me to get some more hardware, and I was in full flow on this.

I tried a clever trick of using rsh to work the speaker from another computer, but it wouldn't, and I don't understand why.

So I decided to do the whole thing from a standard linux box. The next problem was getting the microphone to work, without a terrible amount of noise - that was mostly a matter of using a suitable cable. I have the microphone set to 50% amplification.

So here's what happens. I get a phone call, notice that it's a telemarketer, put the phone on speaker (so that the microphone can pick up the telemarketer, and so that my speaker plays into the microphone of the telephone) and I start up Lenny. Lenny plays a recording, waits for the telemarketer to speak, waits for silence, then plays the next recording. After it plays the 16 sound files, it loops round and plays them again. It's a simple program:

while [ "$something" != 2 ]; do
for chat in $(ls ??.wav); do
echo item: $chat
#rec /tmp/rec.wav rate 32k silence 1 0.1 3% -1 3.0 3% &
rec /tmp/rec.wav rate 32k silence 1 0.1 3% -1 1.0 3% &

sleep 0.5
until [ "$var1" != "$var2" ]; do
    var1=`du -b "/tmp/rec.wav"`
    sleep 1
    var2=`du -b "/tmp/rec.wav"`
echo "Sound Detected"

until [ "$var1" == "$var2" ]; do
    var1=`du -b "/tmp/rec.wav"`
    sleep 1
    var2=`du -b "/tmp/rec.wav"`
echo "Silence Detected"

kill $p
play $chat

No comments:

Post a Comment