Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
fc7aadcd
Commit
fc7aadcd
authored
11 years ago
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UserGUI: initial speechrec with web API + new user options
parent
426ecaed
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
125 additions
and
29 deletions
+125
-29
style.css
Web/htdocs/gui/css/style.css
+34
-2
settings.php
Web/htdocs/gui/footjs/settings.php
+5
-5
page.php
Web/htdocs/gui/includes/page.php
+4
-0
offline.appcache
Web/htdocs/gui/offline.appcache
+1
-1
settings.php
Web/htdocs/gui/pages/settings.php
+2
-2
foot.php
Web/htdocs/gui/parts/foot.php
+45
-10
footbar.php
Web/htdocs/gui/parts/footbar.php
+10
-4
dmdb.py
domotika/db/dmdb.py
+8
-1
domotika.py
domotika/domotika.py
+2
-2
rest.py
domotika/web/rest.py
+10
-1
web.py
domotika/web/web.py
+4
-1
No files found.
Web/htdocs/gui/css/style.css
View file @
fc7aadcd
...
...
@@ -193,6 +193,10 @@
border-radius
:
4px
;
}
/*
input::-webkit-input-speech-button {
opacity: 0;
}*/
.notifybutton
{
background-image
:
url(/resources/img/notification.jpg)
;
background-repeat
:
no-repeat
;
...
...
@@ -211,6 +215,25 @@
.notifybutton
:hover
{
background-color
:
#fff
;
}
.speechbutton
{
background-image
:
url(/resources/img/microphone-little.png)
;
background-repeat
:
no-repeat
;
background-size
:
contain
;
background-color
:
#fff
;
width
:
37px
;
max-width
:
50px
;
height
:
37px
;
padding
:
8px
8px
;
border
:
0px
solid
transparent
;
position
:
absolute
;
bottom
:
5px
;
right
:
410px
;
display
:
none
;
}
.speechbutton
:hover
{
background-color
:
#fff
;
}
.homebutton
{
background-image
:
url(/resources/img/home_small.jpg)
;
...
...
@@ -257,7 +280,7 @@
}
.footbar-form
{
position
:
absolute
;
right
:
1
10
px
;
right
:
1
05
px
;
width
:
300px
;
bottom
:
-2px
;
}
...
...
@@ -265,7 +288,7 @@
.footbar-form-sm
{
position
:
absolute
;
left
:
5px
;
width
:
10
0px
;
width
:
8
0px
;
bottom
:
-2px
;
}
...
...
@@ -437,6 +460,15 @@
}
@media
(
max-width
:
768px
)
{
.speechbutton
{
left
:
88px
;
right
:
auto
;
}
}
@media
(
max-width
:
992px
)
{
.panel-media-low
{
height
:
auto
!important
;
...
...
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/footjs/settings.php
View file @
fc7aadcd
...
...
@@ -9,17 +9,17 @@ var updateUser = function(r) {
$
(
"#email"
).
val
(
r
.
data
.
email
);
$
(
"#desktophome"
).
val
(
r
.
data
.
desktop_homepath
);
$
(
"#mobilehome"
).
val
(
r
.
data
.
mobile_homepath
);
$
(
"#lang"
).
val
(
r
.
data
.
language
);
$
(
"#webspeech"
).
val
(
r
.
data
.
webspeech
);
$
(
"#speechlang"
).
val
(
r
.
data
.
speechlang
);
if
(
r
.
data
.
tts
==
1
)
$
(
'#tts-switch'
).
bootstrapSwitch
(
'setState'
,
true
);
//$("#tts").attr('checked', true);
else
$
(
'#tts-switch'
).
bootstrapSwitch
(
'setState'
,
false
);
//$("#tts").attr('checked', false);
if
(
r
.
data
.
slide
==
1
)
$
(
'#slide'
).
bootstrapSwitch
(
'setState'
,
true
);
$
(
'#slide
-switch
'
).
bootstrapSwitch
(
'setState'
,
true
);
else
$
(
'#slide'
).
bootstrapSwitch
(
'setState'
,
false
);
$
(
"#lang"
).
val
(
r
.
data
.
language
);
$
(
"#webspeech"
).
val
(
r
.
data
.
webspeech
);
$
(
"#speechlang"
).
val
(
r
.
data
.
speechlang
);
$
(
'#slide-switch'
).
bootstrapSwitch
(
'setState'
,
false
);
$
(
"#userform"
).
show
();
};
...
...
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/includes/page.php
View file @
fc7aadcd
<!DOCTYPE html>
<?
/*
<html manifest="<?=$BASEGUIPATH?>/offline.appcache">
*/
?>
<html>
<head>
<?=
$PAGE_BUFFER
[
'head'
]
?>
<?=
$PAGE_ADDHEAD
?>
...
...
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/offline.appcache
View file @
fc7aadcd
CACHE MANIFEST
# rev 138887536
1
# rev 138887536
3
/resources/img/logo_icon.png
NETWORK:
*
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/pages/settings.php
View file @
fc7aadcd
...
...
@@ -71,7 +71,7 @@
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"
lang
"
class=
"col-lg-2 control-label"
>
Web Speech rec.:
</label>
<label
for=
"
webspeech
"
class=
"col-lg-2 control-label"
>
Web Speech rec.:
</label>
<div
class=
"col-lg-3"
>
<select
name=
"webspeech"
id=
"webspeech"
class=
"form-control"
>
<option
value=
"no"
>
no
</option>
...
...
@@ -81,7 +81,7 @@
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"lang"
class=
"col-lg-2 control-label"
>
Speech lang:
</label>
<label
for=
"
speech
lang"
class=
"col-lg-2 control-label"
>
Speech lang:
</label>
<div
class=
"col-lg-3"
>
<select
name=
"speechlang"
id=
"speechlang"
class=
"form-control"
>
<option
value=
"en-US"
>
US English
</option>
...
...
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/parts/foot.php
View file @
fc7aadcd
...
...
@@ -25,14 +25,43 @@
<script src="/resources/EventSource/eventsource.js"></script>
*/
?>
<script
src=
"
<?=
$BASEGUIPATH
;
?>
/js/combined.min.js"
></script>
<!-- <script src="//cdnjs.cloudflare.com/ajax/libs/annyang/1.0.0/annyang.min.js"></script> -->
<?
//if($_DOMOTIKA['webspeech']!="no")
if
(
FALSE
)
{
?>
<script
src=
"/resources/speech/annyang.min.js"
></script>
<?
}
?>
<script>
//document.documentElement.requestFullscreen();
var
ttsEnabled
=
<?=
$_DOMOTIKA
[
'tts'
]
?>
;
var
slideEnabled
=
<?=
$_DOMOTIKA
[
'slide'
]
?>
;
var
speechEnabled
=
'
<?=
$_DOMOTIKA
[
'webspeech'
]
?>
'
;
if
(
speechEnabled
==
'touch'
&&
document
.
createElement
(
'input'
).
webkitSpeech
==
undefined
)
{
testSpeech
=
window
.
webkitSpeechRecognition
||
window
.
mozSpeechRecognition
||
window
.
msSpeechRecognition
||
window
.
oSpeechRecognition
||
window
.
SpeechRecognition
;
if
(
testSpeech
)
{
$
(
"#speechbutton"
).
show
();
// it isn't chrome with webkit-speech attribute, but it support WEB Speech API
}
else
{
$
(
"#speechbutton"
).
hide
();
speechEnabled
==
'no'
;
}
}
else
{
speechEnabled
=
'touch-chrome'
;
}
speechStartWord
=
'*terms'
;
if
(
speechEnabled
==
'continuous'
)
speechStartWord
=
'ok domotica *terms'
;
//var scroller = new AppScroll({
// toolbar: $('#topbar')[0],
// scroller: $('#content')[0]
...
...
@@ -86,7 +115,6 @@
$
.
post
(
"/rest/v1.2/actions/speech_text/json"
,
spobj
.
serialize
(),
speechResult
);
}
/*
// Test SpeechAPI
function
setSpeechText
(
terms
)
{
...
...
@@ -97,17 +125,23 @@
}
var
commands
=
{
'domotica *terms'
: setSpeechText
speechStartWord
:
setSpeechText
};
annyang.init(commands);
annyang.setLanguage('it-IT')
annyang.start();
/*
if(speechEnabled=='touch' || speechEnabled=='continuous')
{
annyang.init(commands);
annyang.setLanguage('
<?=
$_DOMOTIKA
[
'speechlang'
]
?>
');
}
if(speechEnabled=='continuous')
annyang.start();
else if(speechEnabled=='touch')
annyang.recognition.continuous=false;
*/
var
popupFader
=
function
(
ftype
,
title
,
message
,
timeout
){
if
(
typeof
(
timeout
)
===
'undefined'
)
timeout
=
1500
;
$
(
"#alertTitle"
).
text
(
title
);
$
(
"#alertMessage"
).
text
(
" "
+
message
);
r
(
"#alertMessage"
).
text
(
" "
+
message
);
$
(
"#alertPopup"
).
removeClass
();
$
(
"#alertPopup"
).
addClass
(
"alert alert-"
+
ftype
);
$
(
"#alertContainer"
).
fadeIn
(
100
);
...
...
@@ -124,7 +158,8 @@
//dragger: $('#content')[0],
dragger
:
$
(
'[data-domotika-dragger="true"]'
)[
0
],
minDragDistance
:
20
,
slideIntent
:
30
slideIntent
:
30
,
//touchToDrag: slideEnabled
});
<?
}
?>
...
...
This diff is collapsed.
Click to expand it.
Web/htdocs/gui/parts/footbar.php
View file @
fc7aadcd
<?
@
include_once
(
"../includes/common.php"
);
?>
<?
$webspeech
=
""
;
if
(
$_DOMOTIKA
[
'webspeech'
]
==
'touch'
)
$webspeech
=
'x-webkit-speech="x-webkit-speech"'
;
?>
<div
class=
"navbar navbar-fixed-bottom"
>
<a
class=
"navbar-brand"
href=
"http://www.unixmedia.it"
target=
_blank
>
Domotika
1.0
</a>
<a
class=
"navbar-brand"
href=
"http://www.unixmedia.it"
target=
_blank
>
Domotika
</a>
<p
class=
"navbar-text hidden-sm"
><a
href=
"http://www.unixmedia.it"
class=
"navbar-link"
target=
_blank
>
by Unixmedia
</a></p>
<button
id=
"speechbutton"
type=
"button"
class=
"btn btn-default navbar-btn pull-right speechbutton"
></button>
<form
id=
"speech"
class=
"navbar-form footbar-form hidden-sm"
>
<input
type=
"text"
name=
"text"
value=
""
class=
"form-control"
x-webkit-speech=
"x-webkit-speech"
lang=
"it-IT
"
placeholder=
"Command"
>
<input
type=
"text"
id=
"speechinp"
name=
"text"
value=
""
class=
"form-control"
<?=
$webspeech
?>
lang=
"
<?=
$_DOMOTIKA
[
'speechlang'
]
?>
"
placeholder=
"Command"
>
</form>
<form
id=
"speechsm"
class=
"navbar-form footbar-form-sm visible-sm"
>
<input
type=
"text"
name=
"text"
value=
""
class=
"form-control"
x-webkit-speech=
"x-webkit-speech"
lang=
"it-IT
"
placeholder=
"Command"
>
<input
type=
"text"
id=
"speechinp"
name=
"text"
value=
""
class=
"form-control"
<?=
$webspeech
?>
lang=
"
<?=
$_DOMOTIKA
[
'speechlang'
]
?>
"
placeholder=
"Command"
>
</form>
<button
id=
"notifybutton"
type=
"button"
id=
"notifybutton"
class=
"btn btn-default navbar-btn pull-right notifybutton"
>
<button
id=
"notifybutton"
type=
"button"
class=
"btn btn-default navbar-btn pull-right notifybutton"
>
<span
id=
"notifybadge"
class=
"badge"
>
0
</span>
</button>
<a
class=
"btn btn-default navbar-btn pull-right homebutton"
href=
"
<?=
$BASEGUIPATH
;
?>
"
></a>
...
...
This diff is collapsed.
Click to expand it.
domotika/db/dmdb.py
View file @
fc7aadcd
...
...
@@ -748,7 +748,7 @@ def getUsersInGroup(group, activeonly=True):
return
UsersGroup
.
find
(
where
=
[
"group=?"
,
group
])
def
updateUserData
(
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
=
False
,
lang
=
"it"
):
def
updateUserData
(
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
=
False
,
lang
=
"it"
,
slide
=
False
,
webspeech
=
'touch'
,
speechlang
=
'it-IT'
):
def
onRes
(
res
):
if
res
>
0
:
return
defer
.
succeed
(
username
+
" correctly updated"
)
...
...
@@ -763,7 +763,14 @@ def updateUserData(username, pwd, email, dhome, mhome, tts=False, lang="it"):
qstring
+=
",tts=1"
else
:
qstring
+=
",tts=0"
if
slide
:
qstring
+=
",slide=1"
else
:
qstring
+=
",slide=0"
qstring
+=
",webspeech='
%
s'"
%
webspeech
qstring
+=
",speechlang='
%
s'"
%
speechlang
qstring
+=
" WHERE username='
%
s' AND active > 0"
%
(
username
)
log
.
debug
(
qstring
)
return
runOperation
(
qstring
)
.
addCallback
(
onRes
)
...
...
This diff is collapsed.
Click to expand it.
domotika/domotika.py
View file @
fc7aadcd
...
...
@@ -2216,8 +2216,8 @@ class domotikaService(service.Service):
def
web_on_getUserFromName
(
self
,
name
):
return
dmdb
.
Users
.
find
(
where
=
[
'username=?'
,
name
],
limit
=
1
)
def
web_on_updateUserData
(
self
,
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
,
lang
):
return
dmdb
.
updateUserData
(
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
,
lang
)
def
web_on_updateUserData
(
self
,
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
,
lang
,
slide
=
False
,
webspeech
=
'touch'
,
speechlang
=
'it-IT'
):
return
dmdb
.
updateUserData
(
username
,
pwd
,
email
,
dhome
,
mhome
,
tts
,
lang
,
slide
,
webspeech
,
speechlang
)
def
web_on_getMaxLocalTranscode
(
self
):
return
int
(
self
.
config
.
get
(
'media'
,
'localtranscode'
))
...
...
This diff is collapsed.
Click to expand it.
domotika/web/rest.py
View file @
fc7aadcd
...
...
@@ -351,15 +351,24 @@ class UserRest(RestCore):
pwd
=
False
tts
=
False
lang
=
"it"
slide
=
False
webspeech
=
"touch"
speechlang
=
"it-IT"
if
'lang'
in
r
.
keys
():
lang
=
r
[
'lang'
]
if
'tts'
in
r
.
keys
():
tts
=
True
if
'passwd'
in
r
.
keys
()
and
r
[
'passwd'
]
!=
""
:
pwd
=
r
[
'passwd'
]
if
'slide'
in
r
.
keys
():
slide
=
True
if
'webspeech'
in
r
.
keys
()
and
r
[
'webspeech'
]
in
[
'no'
,
'touch'
,
'continuous'
]:
webspeech
=
r
[
'webspeech'
]
if
'speechlang'
in
r
.
keys
()
and
r
[
'speechlang'
]
in
[
'it-IT'
,
'it-CH'
,
'en-US'
,
'en-GB'
]:
speechlang
=
r
[
'speechlang'
]
if
'desktop_homepath'
in
r
.
keys
()
and
'mobile_homepath'
in
r
.
keys
()
and
'email'
in
r
.
keys
():
return
self
.
core
.
updateUserData
(
self
.
session
.
mind
.
perms
.
username
,
pwd
,
r
[
'email'
],
r
[
'desktop_homepath'
],
r
[
'mobile_homepath'
],
tts
,
lang
)
.
addCallbacks
(
onOk
,
onError
)
r
[
'email'
],
r
[
'desktop_homepath'
],
r
[
'mobile_homepath'
],
tts
,
lang
,
slide
,
webspeech
,
speechlang
)
.
addCallbacks
(
onOk
,
onError
)
return
ResponseConversion
(
request
,
code
=
400
,
entity
=
"Bad request - error in parameters"
)
#return self.callbackResponse(self.core.updateUserFromName(self.session.mind.perms.username), request)
...
...
This diff is collapsed.
Click to expand it.
domotika/web/web.py
View file @
fc7aadcd
...
...
@@ -215,7 +215,7 @@ class RootPage(rend.Page):
if
headers
.
hasHeader
(
"DMSESSION"
):
headers
.
removeHeader
(
"DMSESSION"
)
headervalue
=
str
(
session
.
uid
)
cols
=
[
'username'
,
'passwd'
,
'id'
,
'homepath'
,
'email'
,
'tts'
,
'language'
]
cols
=
[
'username'
,
'passwd'
,
'id'
,
'homepath'
,
'email'
,
'tts'
,
'language'
,
'slide'
,
'webspeech'
,
'speechlang'
]
try
:
headervalue
=
session
.
mind
.
perms
.
toHash
(
cols
)
except
:
...
...
@@ -227,6 +227,9 @@ class RootPage(rend.Page):
headervalue
[
'email'
]
=
""
headervalue
[
'tts'
]
=
0
headervalue
[
'language'
]
=
"it"
headervalue
[
'slide'
]
=
0
headervalue
[
'webspeech'
]
=
'touch'
headervalue
[
'speechlang'
]
=
'it-IT'
headervalue
[
'sessionid'
]
=
session
.
uid
headervalue
[
'logged'
]
=
self
.
logged
log
.
debug
(
'DMSESSION SEND '
+
str
(
headervalue
))
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment