Skip to content

Commit 4461d21

Browse files
committed
added stt output to always-on view; my-view reload button does hard-reload
1 parent fc47e54 commit 4461d21

File tree

5 files changed

+68
-6
lines changed

5 files changed

+68
-6
lines changed

www/always-on.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<div id="sepiaFW-alwaysOn-battery"></div>
2626
</div>
2727
</div>
28+
<div id="sepiaFW-alwaysOn-stt-out"></div>
2829
</div>
2930
</div>
3031
</div>

www/css/sepiaFW-alwaysOn.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,18 @@
197197
}
198198
#sepiaFW-alwaysOn-info-box > div {
199199
padding: 4px;
200+
}
201+
202+
#sepiaFW-alwaysOn-stt-out {
203+
height: 42px;
204+
width: 100%;
205+
text-align: center;
206+
color: #aaa;
207+
padding: 0px 24px;
208+
position: absolute;
209+
bottom: 12px;
210+
font-size: 18px;
211+
overflow: hidden;
212+
display: flex;
213+
flex-direction: column-reverse;
200214
}

www/scripts/sepiaFW.alwaysOn.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function sepiaFW_build_always_on(){
4242
onClose: AlwaysOn.onClose,
4343
//onMessageHandler: AlwaysOn.onMessageHandler, //TODO: use this?
4444
onMissedMessageHandler: AlwaysOn.onMissedMessageHandler,
45+
onSpeechToTextInputHandler: AlwaysOn.onSpeechToTextInputHandler,
4546
theme: "dark_full"
4647
});
4748
}
@@ -71,6 +72,7 @@ function sepiaFW_build_always_on(){
7172
$clock = $('#sepiaFW-alwaysOn-clock');
7273
$notes = $('#sepiaFW-alwaysOn-notifications');
7374
$battery = $('#sepiaFW-alwaysOn-battery');
75+
$sttOut = $('#sepiaFW-alwaysOn-stt-out');
7476
}
7577

7678
//On open
@@ -149,6 +151,27 @@ function sepiaFW_build_always_on(){
149151
}
150152
}
151153

154+
//STT input handling
155+
AlwaysOn.onSpeechToTextInputHandler = function(sttResult){
156+
if (sttResult && sttResult.text){
157+
if (sttResult.isFinal){
158+
console.log('AO saw text: ' + sttResult.text);
159+
}else{
160+
//console.log('AO saw text: ' + sttResult.text);
161+
}
162+
$sttOut.html(sttResult.text);
163+
if (fadeSttTimer) clearTimeout(fadeSttTimer);
164+
$sttOut.stop().show();
165+
fadeSttTimer = setTimeout(function(){
166+
$sttOut.stop();
167+
$sttOut.fadeOut(3000, function(){
168+
$sttOut.html("");
169+
});
170+
}, 4000);
171+
}
172+
}
173+
var fadeSttTimer;
174+
152175
//Animations and wake controls:
153176

154177
AlwaysOn.onWakeup = function(){
@@ -323,7 +346,7 @@ function sepiaFW_build_always_on(){
323346
var availableWidth = $('#sepiaFW-alwaysOn-view').width();
324347
var avatarHeigth = $avatar.height();
325348
var avatarWidth = $avatar.width();
326-
var newTop = getRandomPixel(availableHeight-avatarHeigth);
349+
var newTop = getRandomPixel(availableHeight-avatarHeigth-60);
327350
var newLeft = getRandomPixel(availableWidth-avatarWidth);
328351
$avatar.css({top: newTop, left: newLeft});
329352
}

www/scripts/sepiaFW.frames.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function sepiaFW_build_frames(){
1414
//handlers
1515
var onMessageHandler = undefined; //should receive a message object
1616
var onMissedMessageHandler = undefined; //should be triggered when a message was not visible for user (e.g. because frame was open)
17+
var onSpeechToTextInputHandler = undefined; //should show text (and optionally interrim results) that are generated by STT engine
1718

1819
Frames.open = function(info){
1920
//callbacks?
@@ -22,6 +23,7 @@ function sepiaFW_build_frames(){
2223
onFinishSetup = info.onFinishSetup;
2324
onMessageHandler = info.onMessageHandler;
2425
onMissedMessageHandler = info.onMissedMessageHandler;
26+
onSpeechToTextInputHandler = info.onSpeechToTextInputHandler;
2527

2628
//theme
2729
if (info.theme && info.theme == "dark"){
@@ -70,6 +72,7 @@ function sepiaFW_build_frames(){
7072
//handlers reset
7173
onMessageHandler = undefined;
7274
onMissedMessageHandler = undefined;
75+
onSpeechToTextInputHandler = undefined;
7376
}
7477

7578
Frames.setup = function(info, finishCallback){
@@ -134,6 +137,13 @@ function sepiaFW_build_frames(){
134137
Frames.handleMissedMessages = function(msgObject){
135138
if (onMissedMessageHandler) onMissedMessageHandler(msgObject);
136139
}
140+
141+
Frames.canShowSpeechToTextInput = function(){
142+
return !!onSpeechToTextInputHandler;
143+
}
144+
Frames.handleSpeechToTextInput = function(msgObject){
145+
if (onSpeechToTextInputHandler) onSpeechToTextInputHandler(msgObject);
146+
}
137147

138148
return Frames;
139149
}

www/scripts/sepiaFW.webSocket.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,6 @@ function sepiaFW_build_webSocket_client(){
348348
//actions triggered when the client becomes active (in this case when the active channel is obtained)
349349
Client.onActive = function(){
350350
//LOAD SOME MORE STUFF that requires account verification:
351-
352-
//refresh timers
353-
if (SepiaFW.events){
354-
SepiaFW.events.setupTimeEvents();
355-
}
356351

357352
//update myView
358353
SepiaFW.ui.updateMyView(false, true, 'onActive');
@@ -732,6 +727,8 @@ function sepiaFW_build_webSocket_client(){
732727
$(myEventsBtn).off();
733728
$(myEventsBtn).on("click", function () {
734729
SepiaFW.animate.flash(this.id);
730+
SepiaFW.ui.updateMyView(true, true, 'shortcutsButton');
731+
/*
735732
var dataset = {}; dataset.info = "direct_cmd";
736733
dataset.cmd = "events_personal;;";
737734
dataset.newReceiver = SepiaFW.assistant.id;
@@ -741,6 +738,7 @@ function sepiaFW_build_webSocket_client(){
741738
options.showView = true;
742739
options.skipTTS = true;
743740
Client.sendCommand(dataset, options);
741+
*/
744742
closeControlsMenueWithDelay();
745743
});
746744
}
@@ -773,6 +771,14 @@ function sepiaFW_build_webSocket_client(){
773771
if (optimizeAsrResult && (SepiaFW.speech.language === "de") && text && text.match(/^(GTA|GPA|PPA|WPA|dpa|liebherr)( ).+/ig)){
774772
text = text.replace(/^(GTA|GPA|PPA|WPA|dpa|liebherr)( )/i, "Sepia ");
775773
}
774+
775+
//show results in frame as well? (SHOW ONLY!)
776+
if (SepiaFW.frames && SepiaFW.frames.isOpen && SepiaFW.frames.canShowSpeechToTextInput()){
777+
SepiaFW.frames.handleSpeechToTextInput({
778+
"text": text,
779+
"isFinal": true
780+
});
781+
}
776782

777783
//try speech-bubble
778784
var inBox = document.getElementById('sepiaFW-chat-controls-speech-box-bubble');
@@ -799,6 +805,14 @@ function sepiaFW_build_webSocket_client(){
799805
}
800806
}
801807
Client.asrCallbackInterim = function(text){
808+
//show results in frame as well? (SHOW ONLY!)
809+
if (SepiaFW.frames && SepiaFW.frames.isOpen && SepiaFW.frames.canShowSpeechToTextInput()){
810+
SepiaFW.frames.handleSpeechToTextInput({
811+
"text": text,
812+
"isFinal": false
813+
});
814+
}
815+
802816
//try speech-bubble
803817
var inBox = document.getElementById('sepiaFW-chat-controls-speech-box-bubble');
804818
if (inBox){

0 commit comments

Comments
 (0)