RunBASIC Voice Recognition for android

new BookmarkLockedFalling
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Post by mmiscool on Feb 22, 2013 22:01:03 GMT -5

Hello

I have been doing some home automation work and one thing I wanted was to control things in my home using voice recognition.

I was able to fill this goal by developing an app for my android phone that exploits googles voice recognition technology and the run basic server to control lights, fans and other things in my home.

I have a video that better enplanes some of this.

[フレーム]

I will be posting the link for the app in the google play store but it takes a couple of hours for it to be published in the indexes so stay tuned.
play.google.com/store/apps/developer?id=app+awesomesoft
It is called "RB Voice"


The code for the run basic server is as follows.
Keep in mind this project must be published

You can add commands that it will respond to by adding more options in the case statement. This example is a basic note taking application but can be added to to make it do any thing from running a program to running another RB Application.

app.usr$ = mid$(UrlKeys$ ,1+INSTR(UrlKeys,ドル "$"))
prodject.username$ = app.name$

app.name$ = mid$(UrlKeys$ ,1+INSTR(UrlKeys,ドル "&"))
app.name$ = left$(app.name$ ,INSTR(app.name,ドル "$")-1)

GLOBAL Command.in$
Command.in$ = upper$(ReplaceString$("%20"," ",app.name,ドル"all",0))


print app.usr$
print Command.in$



select case 1
case check.command("new note")
open "Notes.txt" for append as #mike
print #mike, right$(Command.in,ドル len(Command.in$)-len("NOTE NEW"))
close #mike

case check.command("show notes")

open "Notes.txt" for input as #f
while not(eof(#f))
x = x + 1
line input #f, a$
print x;" - :";a$
wend
close #f


case check.command("delete note number")


open "Notes.txt" for input as #f
while not(eof(#f))
x = x + 1
line input #f, a$
if str$(x) <> word$(Command.in,4ドル) then
output.a$ = output.a$ ;a$;chr$(13)
end if
wend
close #f

output.a$ = left$(output.a,ドルlen(output.a$)-1)
open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for output as #mike
print #mike, output.a$
close #mike


wait
end select
end


FUNCTION check.command(command$)
if upper$(command$) = left$(Command.in,ドル len(command$)) then check.command = 1
end function



In the app on the phone to set it up all you have to do is hit the change home url button.
Enter the url for the published application you just made with a & on the end of it as shown below.


http://localhost/seaside/go/runbasicpersonal?app=VoiceActive&

Replace "localhost" with your servers ip addres or domain and replace "VoiceActivate" with the name of the published project on the rb server.
be sure to keep the "&" symbol on the end otherwise you will be returned an error.

The key code feild is the username and can be useful for assiging permissions on the system. It is able to identify the device issuing the command to the system on the RB side of thingd
Last Edit: Feb 22, 2013 22:05:09 GMT -5 by mmiscool
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Last Edit: Apr 15, 2013 21:11:28 GMT -5 by mmiscool
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Post by mmiscool on Apr 15, 2013 21:19:04 GMT -5

Hello all,

I have been playing with this app and using it for my home security system and other home automation functions.

One thing that i wanted was to make it so that you could activate the speech recognition with the button on a blue tooth head set.

I have been able to do that using this app.

forum.xda-developers.com/showthread.php?t=836243

The latest beta apk works best for me. There is a version in the google play market for free but it seems to have a problem on my device.

All you have to do is download this and set it to use "RB Voice" screen 1 as the default button action.

There will be more to come on this but for now I think this is about it.

On a side note has any one else used run basic to do home automation tasks or am I the only one out there doing this kind of stuff.

If there is any one out there who is doing this kind of stuff give a shout and may be we can compare notes :-)

-Mike
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Post by mmiscool on Sept 16, 2013 14:27:50 GMT -5

I am now officially documenting some of the features of the app.

As you can see in the code below if you respond to the the request with sertan things set as the page title you can make the app on the user device do different things.

If you set the page title to "speek Hello world" if will use the text to speech feature on the device to speak out the text you want and then automatically close the app.

if you set the page title to "navto 123 street name, zip code" it will bring up the gps automatically and start trip guidance using Google navigate/maps and automatically close the app.

if you set the page title to "result " it simply display the information the web server returns with out automatically closing after the command has run

if you set the page title to "makecall 8605551234 " it will dial that number from your device.

I can add more functionality as new needs are encountered but I think I have covered the basics with this list.


To set the title of the page that gets returned to the embed browser in this app I have found the best way to use the flowing code.

cls
html "<script>document.title = 'result';</script>"
print "Any kind of information you want to display on the phones screen"

Simply replace result with the command you want to send back to the app.


app.usr$ = mid$(UrlKeys$ ,1+INSTR(UrlKeys,ドル "$"))
prodject.username$ = app.name$
'print app.usr$

'print "app name:"
app.name$ = mid$(UrlKeys$ ,1+INSTR(UrlKeys,ドル "&"))
app.name$ = left$(app.name$ ,INSTR(app.name,ドル "$")-1)


GLOBAL command.arguments$
GLOBAL Command.in$
Command.in$ = upper$(ReplaceString$("%20"," ",app.name,ドル"all",0))


print app.usr$
print Command.in$



select case 1

case check.command("new note")
open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for append as #mike
print #mike, command.arguments$
close #mike

case check.command("show notes")
html "<script>document.title = 'speek "
open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for input as #f
while not(eof(#f))
x = x + 1
line input #f, a$
html x;" - :";a$;". "
wend
close #f
html "';</script>"


x = 0
open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for input as #f
while not(eof(#f))
x = x + 1
line input #f, a$
print x;" - :";a$
wend
close #f
print "hello"

case check.command("delete note number")


open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for input as #f
while not(eof(#f))
x = x + 1
line input #f, a$
if str$(x) <> change.to.no$(command.arguments$) then
output.a$ = output.a$ ;a$;chr$(13)
end if
wend
close #f

output.a$ = left$(output.a,ドルlen(output.a$)-1)
open "SMBI-OS\users\";prodject.username$;"\UserFiles\Notes.txt" for output as #mike
print #mike, output.a$
close #mike





case check.command("time")
html "<script>document.title = 'speek "
html time$("hh mm")
html "';</script>"

case check.command("navigate")
html "<script>document.title = 'navto "
html command.arguments$
html "';</script>"



case check.command("run")
cls
html "<script>document.title = 'result';</script>"
run right$(Command.in,ドル len(Command.in$)-len("RUN")), #appthing
#appthing set.usr.name$(app.usr$)
render #appthing


case check.command("Help")
html "<script>document.title = 'result';</script>"


print "new note"
print "show notes"
print "delete note number"
print "time"
print "navigate"
print "run"



wait
end select
end


FUNCTION check.command(command$)
if upper$(command$) = left$(Command.in,ドル len(command$)) then
check.command = 1
command.arguments$ = right$(Command.in,ドル len(Command.in$)-len(command$)-1)
end if

end function
Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654
super
New Member
*

super Avatar

Posts: 1

Mystic
New Member
*

Mystic Avatar

Posts: 29

Post by Mystic on Jan 19, 2014 20:33:35 GMT -5

I was entertaining the idea of using RB for home automation myself.

One plan I had was to try and identify when my family members where home. To achieve this, I use a program on the Mac called, "IP Scanner Pro" which will export logs for every scan. Since the log shows what devices are connected to the network, it knows when my family member is in the house by their cell phone connecting to my wireless access point.

Why do this? Well, because if the house does not "sense" my daughter is home for the past 10 minutes, but her lights are still on, the lights can be turned off.

When the house doe not "sense" anyone home it can drop the temperature and turn off all unnecessary lighting. :)

Just an idea.
- Rick
mmiscool
Full Member
***

mmiscool Avatar

Send me a message if you want to help with a WEB OS project
Posts: 106

Post by mmiscool on Jan 20, 2014 15:12:56 GMT -5

Hello there.

I have actually been feverishly updating my app to add more interactivity to it and I created a nice interface for adding commands to it.

If you would like to play with my code I can tell you it is much improved from what it was when I published it.


I have added functions to my rb program and made it so that adding new commands is effortless with a small program that asks you for the command name and the code for that particular command. It manages the source code for the engine and makes adding new commands much easier.


if you have some time and would like to talk about it and get a copy of my source I can PM you my cell or google talk account.

I can also prepare a package for you my code and other useful functions. This project really grew out of my web os project witch you can see on the announcements board.

And yes. I can do a demo about how to use App inventor. I have had a small issue publishing my latest version on google play because the app inventor development environment has changed and is no longer using the same key to sign code. I will how ever be publishing a new version of the app. same name. slightly different interface. and a couple of more features. I can send you the apk and source for it also if you wish to improve on it and take advantage of other native android functionally.

Check out the code wiki at http://smbisoft.com[br]The code wiki allows for multiple users to work on the same project at the same time in just basic.[br][br]SMBISoft ____888-LAN-Zoli _____ 888-526-9654