STEEMPI is Talking! + a few possible solutions for blinking the LED on updates (Help needed Curl/Steemsql/Bash script/PHP)

in #steemdev7 years ago (edited)

Steempi is talking!

One of the smarthome like features that would be nice to have is that Steempi could talk, once this feature is integrated it can notify "New upvote", "New comment" "New transfer" and it could even read replies for us. and possible do other things in the future.

i have played around a bit with speech to text before on my other Raspberry Pi robotic project, and using and integrating  speech to text to a project is not that difficult, and easy to install.

It would be nice if STEEMPI beside blinking the notification LED also can give spoken notifications.

In this update i will share the struggle and results of the past few days to try and make those things work and hope you have some feedback to solve the issues.

(im not a good programmer but have big passion for technology and want to make this work for all of us)

 

Making Steempi talk

To make Steempi talk its first few words, sentences  and commands  i used a program called "festival"

How does it work

Instead of echo the results to the screen we can use echo to Festival, and Festival will use text to speech to read the results which can be heard on the connected speakers. 

(on TV speakers over HDMI or speakers connected to the 3,5mm jack)

Installing festival:
sudo apt-get install festival

Example command to speak a sentence:
echo Just what do you think youre doing, Dave? | festival --tts 

Example command to speak out the IP address of the Pi:
hostname -I | festival --tts

Progress on blinking the led on new upvotes / replies and transfers

The best way probably is to use the Steemit api, SteemSQL or Steemdata. i have looked into the tutorials here on Steemit and have asked around and try implement them but i could not adjust the given methods so i searched for  a work around.

The first work around i tried to get information from Steemit.com was to use a website called IFTTT to forward the new replies to my email. but this approach updates to slow to be useable for this project.

The other work around i tried is with Curl, Curl can check a website for changes and it should be possible to compare 2 websites.

If the website changes, it could run a command (the LED on command.)

This would be more preferable than the first work around because it is more pure and running on the PI instead of a external website.

Found this Curl Bash script that had good ratings:

#!/bin/bash
while [ 1 ];
do
    count=`curl -s "www.nba.com" | grep -c "Basketball"`
    if [ "$count" != "0" ]
    then
       echo "www.nba.com updated!"
       exit 0   
    fi
    sleep 600   
done


And changed it to:

#!/bin/bash
while [ 1 ];
do
    count=`curl -s "https://steemit.com/@techtek/comments" | grep -c "RE:"`
    if [ "$count" != "0" ]
    then
       echo "New Reply to your account"
       exit 0   
    fi
    sleep 600   
done

It runs but i think it doesn't work because of the https://steemit.com/@techtek/comments website doesn't have a preloaded end, and counting "RE:" will always result in the same result for that reason .(?)

Other options

Other software beside Curl that can maybe solve the problem and check steemit.com for changes and possibly blink the LED on website changes are: urlwatch, Specto and Newsbeuter. a other and probably more prefurable way would be with SteemSQL and PHP.

To control the LED from within PHP i made this simple PHP example to blink the LED that is connected to the Raspberry Pi board:

PHP LED Example:

<?php
// make pin 0 a output pin
exec('gpio mode 0 out');

// turn pin 0 on and off (blink x3 with one second interval)
exec('gpio write 0 1');
sleep(1);
exec('gpio write 0 0');
sleep(1);
exec('gpio write 0 1');
sleep(1);
exec('gpio write 0 0');
sleep(1);
exec('gpio write 0 1');
sleep(1);
exec('gpio write 0 0');
?>


Having automated Steemit LED notification is come closer and a few first options are available to play around with, can you make it work and make it become a reality Do you know how to connect with for example SteemSQL and make the LED blink on new upvotes, replies and transfers ?

Do you know how to light up this project , (and literally my day)

it should be possible with some simple but smart solution, and a few lines of code, in a Bash script or from within PHP with SteemSQL.
 

Let's get in touch and work together !

The Steempi project as well as my other projects are time consuming and I always try to provide some unique things to the community. What keeps me going  is your feedback, comments and support. For that reason I would very much like to get some feedback from you, and please feel free to contact me.

Please help and participate, what solution can you implement or suggest to blink the LED, and make SteemPi (Festival) be more informative and dynamic with her notifications?

More about this project:
"Introducing STEEMPI"
"3d printed case with Steemit logo" 



Sort:  

May be you can have a look to piston-cli, it will probably help you to prototype a few things. Follows the link to the commands.

Example: piston read "@techtek/steempi-is-talking-a-few-possible-solutions-for-blinking-the-led-on-updates-help-needed-curl-steemsql-bash-script-php" --comments

Thanks for your reply, installation went ok

"pip3 install --user steem-piston"

but when i try to do "piston addkey" it gives this error

pi@raspberrypi:~ $ piston addkey
Traceback (most recent call last):
File "/usr/local/bin/piston", line 5, in module
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2876, in module
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 449, in _build_master
ws.require(requires)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 745, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pycrypto>=2.6.1

When i check the python version its 2.7.9

When i tr to install python 3 it says latest version already installed

Which distro are you running on your pi ?

PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"

May be try this to force reinstall of pycrypto:
sudo apt-get install libffi-dev libssl-dev
pip3 install --user cryptography --force-reinstall

1 upgraded, 3 newly installed, 0 to remove and 134 not upgraded.

Do you want to continue? [Y/n] y
Abort.

after that still same error when running "piston addkey"

Any suggestions ?

(i just send this error to @xeroc the maker of piston)

Also found someone with the same error code and he suggest to

git clone https://github.com/xeroc/piston

but the given solution result in the same error

thank you for information friend

Just found this new tutorial in the Steemit chat "steemsql channel"

The tutorial has a example code to connect to SteemSQL and this works, now again a bit more close to making the notification work!

Thanks @magicmonk !

https://steemit.com/cn/@magicmonk/php-steemsql-using-php-to-connect-to-the-steemsql-database

This post has received a 0.98 % upvote from @booster thanks to: @techtek.

my first experience with text to speech was on an amiga 500 :) back in 1987 i think it was.
it looks like a fun project , good luck

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 64210.52
ETH 2627.33
USDT 1.00
SBD 2.76