NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 68 69 70 71 72 … 93 Next »
Bluetooth presence, GBPVR and Festival text-to-speech recordings announcements

 
  • 0 Vote(s) - 0 Average
Bluetooth presence, GBPVR and Festival text-to-speech recordings announcements
angryant
Offline

Junior Member

Posts: 16
Threads: 2
Joined: Jul 2005
#1
2005-08-29, 02:09 PM (This post was last modified: 2005-08-29, 09:35 PM by angryant.)
I have a Linux (Fedora Core 4) box at home that performs a number of interesting functions including acting as a Bluetooth presence server. When I get home a cron script running every 5 minutes grep's for the MAC address of my mobile phone using the bluetooth hcitool. Once detected it fires off several activities and plays me a little greeting message letting me know how long I've been out and how many emails are waiting etc.

I finally got around to also linking presence to GBPVR. In PostProcessing.bat I added:

echo %1 >> c:\btp\recordings.txt

(the >> appends)

check.sh runs on my linux box and does the following:
#!/bin/sh
# grep for my phone
/usr/bin/hcitool con | grep -q "00:0E:07:E8:07:7E" || (hcitool scan | grep "00:0E:07:E8:07:7E" && hcitool cc 00:0E:07:E8:07:7E )


I created a Windows Share on my GBPVR machine and then mount that share using Samba (also in check.sh):

mount -t smbfs //anya/btp /mnt/btp -o username=foo,password=bar

check.sh maintains my status in where, awaydate and homedate:

# get last status
exec 6<&0
exec < /opt/btp/where
read a1
LASTSTATUS=$a1
exec 0<&6 6<&-

# get last status
exec 5<&0
exec < /opt/btp/homedate
read a1
HOMEDATE=$a1
exec 0<&5 5<&-

# get away date
exec 7<&0
exec < /opt/btp/awaydate
read a1
AWAYDATE=$a1
exec 0<&7 7<&-

# get last recorded shows
exec 4<&0
exec < /mnt/btp/recordings.txt
read a1
read a2
read a3
read a4
read a5
read a6

LASTSHOW1=$a2
LASTSHOW2=$a3
LASTSHOW3=$a4
LASTSHOW4=$a5
LASTSHOW5=$a6

exec 0<&4 4<&-

# parse out the path
echo "Last 5 recorded shows:"
LASTSHOW1=${LASTSHOW1/\"C:recordings/}
LASTSHOW2=${LASTSHOW2/\"C:recordings/}
LASTSHOW3=${LASTSHOW3/\"C:recordings/}
LASTSHOW4=${LASTSHOW4/\"C:recordings/}
LASTSHOW5=${LASTSHOW5/\"C:recordings/}


# extract the directory for the show name announcement
SAYLASTSHOW1=$( echo $LASTSHOW1 | awk '{ show = $1 "-" $2 "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9; split(show,shows,"_"); l = length(shows[1]) } { print substr(shows[1], 0, (l/2))}' )
SAYLASTSHOW2=$( echo $LASTSHOW2 | awk '{ show = $1 "-" $2 "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9; split(show,shows,"_"); l = length(shows[1]) } { print substr(shows[1], 0, (l/2))}' )
SAYLASTSHOW3=$( echo $LASTSHOW3 | awk '{ show = $1 "-" $2 "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9; split(show,shows,"_"); l = length(shows[1]) } { print substr(shows[1], 0, (l/2))}' )
SAYLASTSHOW4=$( echo $LASTSHOW4 | awk '{ show = $1 "-" $2 "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9; split(show,shows,"_"); l = length(shows[1]) } { print substr(shows[1], 0, (l/2))}' )
SAYLASTSHOW5=$( echo $LASTSHOW5 | awk '{ show = $1 "-" $2 "-" $3 "-" $4 "-" $5 "-" $6 "-" $7 "-" $8 "-" $9; split(show,shows,"_"); l = length(shows[1]) } { print substr(shows[1], 0, (l/2))}' )

echo "$SAYLASTSHOW1"
echo "$SAYLASTSHOW2"
echo "$SAYLASTSHOW3"
echo "$SAYLASTSHOW4"
echo "$SAYLASTSHOW5"

if [ ! $SAYLASTSHOW1 = "----" ]; then
SAYLASTSHOW1="While you were away I recorded $SAYLASTSHOW1"
fi

if [ ! $SAYLASTSHOW2 = "----" ]; then
SAYLASTSHOW2="and $SAYLASTSHOW2"
fi

if [ ! $SAYLASTSHOW3 = "----" ]; then
SAYLASTSHOW3="and $SAYLASTSHOW3"
fi

if [ ! $SAYLASTSHOW4 = "----" ]; then
SAYLASTSHOW4="and $SAYLASTSHOW4"
fi

if [ ! $SAYLASTSHOW5 = "----" ]; then
SAYLASTSHOW5="and $SAYLASTSHOW5"
fi


NOWSTATUS=none

echo "Last status: $LASTSTATUS"
echo "Last away date: $AWAYDATE"
echo "Last home date: $HOMEDATE"

# unquote this for testing
# LASTSTATUS=away

# check presence
if hcitool con | grep -q "00:0E:07:E8:07:7E"
then
if [ $LASTSTATUS = away ]; then
echo "home" > /opt/btp/where
echo $(date) > /opt/btp/homedate
echo "$(date) HOME" >> /opt/btp/tracking
NOWSTATUS=home
fi
else
if [ $LASTSTATUS = home ]; then
echo "away" > /opt/btp/where
echo $(date) > /opt/btp/awaydate
echo "$(date) AWAY" >> /opt/btp/tracking
NOWSTATUS=away
fi
fi



# now home event
if [ $NOWSTATUS = home ]; then

# calculate away time
(( ss = `date +%s` - `date -u --date "$AWAYDATE" +%s`))
(( mm = ss / 60 ))
(( ss = ss % 60 ))
(( hh = mm / 60 ))
(( mm = mm % 60 ))

if [ $hh -gt 0 ]; then
SAYHH="$hh hour"
fi

if [ $hh -gt 1 ]; then
SAYHH="$hh hours"
fi

if [ $hh -gt 0 ] && [ $mm -gt 0 ]; then
SAYANDMIN="and"
fi

if [ $mm -gt 0 ]; then
SAYMM="$mm minute"
fi

if [ $mm -gt 1 ]; then
SAYMM="$mm minutes"
fi

# reset recorded shows
echo "[recordings]" > /mnt/btp/recordings.txt

echo "You have been away from home for $SAYHH $SAYANDMIN $SAYMM"

if [ $hh = 0 ] && [ $mm -lt 16 ]; then
echo "Less than 15 minutes or less away, no voice annoucement"
else
echo "Welcome home Anthony. You have been away from home for $SAYHH $SAYANDMIN $SAYMM. $SAYLASTSHOW1 $SAYLASTSHOW2 $SAYLASTSHOW3 $SAYLASTSHOW4 $SAYLASTSHOW5." | festival --tts
fi
fi

# now away event
if [ $NOWSTATUS = away ]; then
echo "Anthony is now away"
fi

if [ $NOWSTATUS = none ]; then
echo "No change in Anthony's presence"
fi


Obviously, this assumes you have already installed Festival, correctly configured your appropriate default ALSA sound device, configured Bluetooth, enabled Bluetooth on your phone, obtainied the MAC address of your phone, and well.. have Linux. I have yet to find a good way of doing a Bluetooth device scan in Windows, but it's a trivial task in Linux. This is not meant to be an exhaustive step-by-step on getting you running, but will be of interest to some I guess. Cool never the less.

The result is when you walk in the door and your Bluetooth phone is automatically detected, you get a nice voice telling you what has been recorded while you were out. A similar approach under Windows would require you to manually connect to the device by right clicking on the device in your Bluetooth manager.
SkyPVR & Dedicated HTPC
Shuttle SN45GV3 AMD Sempron 3000+
1GB Dual DDR400 RAM 600GB HD
ATI Radeon 9200SE 128MB (TV out)
Hauppauge PVR-350 PCI
RedRat3 USB Infrared Controller
Pace 430-N Sky Digibox
JS Technology RGB to S-Video Converter, Active VIDEO Buffer & Master SCART Controller
ShinyBox S-Video Splitter
Nikkai gold interconnects

FreeViewPVR & Primary Workstation
Shuttle SN95G5 AMD Athlon64 3500+
2GB Dual DDR400 RAM 450GB HD
MSI GeForce 6800GT 256MB
Hauppauge Nova-T-USB2
angryant
Offline

Junior Member

Posts: 16
Threads: 2
Joined: Jul 2005
#2
2005-08-29, 06:30 PM
One enhancement, using the NOWSTATUS=none and then LASTSTATUS=home, this will make annoucements straightaway for each recorded show as it happens if your Bluetooth presence is detected (ie. you are home), otherwise it will save up all the recorded programs in recordings.txt until you get home and then use the previous if-block that plays back all the recorded shows when your bluetooth presence is initially detected. This way you only trully here stuff recorded while you were out, and get ongoing annoucements of stuff recorded while you are home.

if [ $NOWSTATUS = none ]; then
echo "No change in Anthony's presence"
if [ $LASTSTATUS = home ]; then
# reset recorded shows
echo "[recordings]" > /mnt/btp/recordings.txt

# as Anthony is home, announce any recorded shows as it happens
if [ ! $SAYLASTSHOW1 = "----" ]; then
SAYLASTSHOW1="I have just recorded a TV program called: $SAYLASTSHOW1"
echo "$SAYLASTSHOW1 $SAYLASTSHOW2 $SAYLASTSHOW3 $SAYLASTSHOW4 $SAYLASTSHOW5 $SAYLASTSHOW6 $SAYLASTSHOW7 $SAYLASTSHOW8 $SAYLASTSHOW9." | festival --tts
fi
fi
fi
SkyPVR & Dedicated HTPC
Shuttle SN45GV3 AMD Sempron 3000+
1GB Dual DDR400 RAM 600GB HD
ATI Radeon 9200SE 128MB (TV out)
Hauppauge PVR-350 PCI
RedRat3 USB Infrared Controller
Pace 430-N Sky Digibox
JS Technology RGB to S-Video Converter, Active VIDEO Buffer & Master SCART Controller
ShinyBox S-Video Splitter
Nikkai gold interconnects

FreeViewPVR & Primary Workstation
Shuttle SN95G5 AMD Athlon64 3500+
2GB Dual DDR400 RAM 450GB HD
MSI GeForce 6800GT 256MB
Hauppauge Nova-T-USB2
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Import/export recordings via API? whurlston 4 3,826 2019-02-19, 11:48 AM
Last Post: Graham
  Conflict recordings scJohn 1 2,601 2018-03-23, 07:43 PM
Last Post: sub
  API / web call for setting recordings Pbathuk 2 3,332 2018-01-13, 05:17 AM
Last Post: Pbathuk
  API access to artwork and deleting recordings cncb 29 15,741 2016-11-06, 02:20 AM
Last Post: mvallevand
  How to move recordings without them getting deleted from db drmargarit 4 3,926 2015-09-27, 05:33 PM
Last Post: sub
  Best approach to creating recurring recordings from c# drmargarit 0 2,632 2015-09-27, 01:32 AM
Last Post: drmargarit
  TitanTv Remote Schedule For GBPVR UncleJohnsBand 51 33,928 2015-08-20, 05:11 PM
Last Post: sub
  Changing the recording priority on recurring recordings cbgifford 4 3,832 2014-08-17, 03:13 PM
Last Post: Kiwi
  How does NextPVR group recordings for XBMC? spinnaker 2 2,321 2013-11-21, 01:33 AM
Last Post: spinnaker
  Web API call for Ready recordings? bgowland 2 1,887 2013-11-03, 12:43 AM
Last Post: bgowland

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode