Skip to content

Commit 891e162

Browse files
committed
improved reconnect; added experimental settings (STT language, webplayer)
1 parent 1a38ef1 commit 891e162

10 files changed

+213
-67
lines changed

www/css/sepiaFW-style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,10 @@ body {
838838
font-size: 14px;
839839
}
840840
}
841+
.sepiaFW-menu-experimental {
842+
display: none;
843+
margin-left: 16px !important;
844+
}
841845
#sepiaFW-chat-menu li span {
842846
float: left;
843847
padding-right: 8px;

www/scripts/sepiaFW.app.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function sepiaFW_build_config(){
114114
Config.appLanguage = language; //TODO: interface reload to set texts?
115115
//speech
116116
if (SepiaFW.speech){
117-
SepiaFW.speech.language = language;
117+
SepiaFW.speech.setLanguage(language);
118118
SepiaFW.speech.refreshVoice();
119119
}
120120
//geocoder

www/scripts/sepiaFW.audio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ function sepiaFW_build_audio(){
448448
"&format=" + encodeURIComponent(sound_format) +
449449
//general stuff
450450
"&env=" + encodeURIComponent(SepiaFW.config.environment) +
451-
"&lang=" + encodeURIComponent((SepiaFW.speech)? SepiaFW.speech.language : SepiaFW.config.appLanguage) +
451+
"&lang=" + encodeURIComponent((SepiaFW.speech)? SepiaFW.speech.getLanguage() : SepiaFW.config.appLanguage) +
452452
"&KEY=" + encodeURIComponent(SepiaFW.account.getKey()) +
453453
"&client=" + encodeURIComponent(SepiaFW.config.clientInfo),
454454
timeout: 10000,

www/scripts/sepiaFW.client.controls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function sepiaFW_build_client_controls(){
118118
Controls.media = function(controlData){
119119
if (controlData && controlData.action){
120120
//STOP
121-
if (controlData.action == "stop" || controlData.action == "pause"){
121+
if (controlData.action == "stop" || controlData.action == "pause" || controlData.action == "close"){
122122
//Stop internal player
123123
var isInternalPlayerStreaming = SepiaFW.audio.isMusicPlayerStreaming() || SepiaFW.audio.isMainOnHold();
124124
if (isInternalPlayerStreaming){

www/scripts/sepiaFW.local.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function sepiaFW_build_strings(){
3737
StringsDE.noConnectionToServer = 'Es tut mir leid, aber ich konnte keine Verbindung zum Server herstellen :-(';
3838
StringsDE.noConnectionToAssistant = 'Dein Assistent macht gerade Kaffeepause, ist sicher gleich zurück! (hoffentlich)';
3939
StringsDE.noConnectionOrNoCredentials = 'Verbindung ist verloren gegangen oder die Login Daten sind abgelaufen. Du kannst warten und es noch einmal versuchen, die App neu laden oder dich erneut einloggen.';
40+
StringsDE.messageLost = 'Die letzte Nachricht konnte nicht zugestellt werden';
4041
StringsDE.noAsrSupport = 'Es tut mir leid, aber dieser Client unterstütz die Spracherkennung leider nicht :-(';
4142
StringsDE.asrMissingServer = 'Mir fehlen noch Server Informationen um diese Spracherkennungsengine nutzen zu können, check noch mal die Settings bitte (ASR server).';
4243
StringsDE.asrSettingsProblem = 'Mikrofon nicht richtig erkannt oder Zugriff verweigert.';
@@ -53,6 +54,7 @@ function sepiaFW_build_strings(){
5354
StringsDE.store = 'Speichern';
5455
StringsDE.load = 'Laden';
5556
StringsDE.tryAgain = 'Nochmal versuchen';
57+
StringsDE.tryReconnect = 'Neu verbinden';
5658
StringsDE.wait = 'Warten';
5759
StringsDE.forget = 'Vergessen';
5860
StringsDE.abort = 'Abbrechen';
@@ -119,6 +121,11 @@ function sepiaFW_build_strings(){
119121
StringsDE.myNewsDemoBtn = 'Öffne meine persönlichen News';
120122
StringsDE.myRadioDemoBtn = 'Starte mein Lieblingsradio';
121123
StringsDE.myToDoDemoBtn = 'Öffne meine To-Do Liste';
124+
//Connection status
125+
StringsDE.status_connecting = "Wird verbunden...";
126+
StringsDE.status_opened = "Online";
127+
StringsDE.status_closed = "Offline";
128+
StringsDE.status_error = "Error";
122129
//Teach-UI
123130
StringsDE.command = 'Befehl';
124131
StringsDE.chooseCommand = 'Bitte wähle einen Befehl.';
@@ -154,6 +161,7 @@ function sepiaFW_build_strings(){
154161
StringsEN.noConnectionToServer = 'I\'m sorry but I could not establish a connection to the server :-(';
155162
StringsEN.noConnectionToAssistant = 'Your assistant is taking a coffee break, will be right back! (hopefully)';
156163
StringsEN.noConnectionOrNoCredentials = 'Connection was lost or credentials became invalid. You can wait and try it again, reload the app or login again.';
164+
StringsEN.messageLost = 'The last message could not be delivered';
157165
StringsEN.noAsrSupport = 'I\'m sorry but this client does not support speech recognition :-(';
158166
StringsEN.asrMissingServer = 'I\'m missing some server info to user this speech recognition engine, please check the settings again (ASR server).';
159167
StringsEN.asrSettingsProblem = 'Microphone has not been recognized properly or access was denied.';
@@ -170,6 +178,7 @@ function sepiaFW_build_strings(){
170178
StringsEN.store = 'Store';
171179
StringsEN.load = 'Load';
172180
StringsEN.tryAgain = 'Try again';
181+
StringsEN.tryReconnect = 'Try reconnect';
173182
StringsEN.wait = 'Wait';
174183
StringsEN.forget = 'Forget';
175184
StringsEN.abort = 'Abort';
@@ -237,6 +246,11 @@ function sepiaFW_build_strings(){
237246
StringsEN.myNewsDemoBtn = 'Open my personal news';
238247
StringsEN.myRadioDemoBtn = 'Start my favorite radio station';
239248
StringsEN.myToDoDemoBtn = 'Open my to-do list';
249+
//Connection status
250+
StringsEN.status_connecting = "Connecting...";
251+
StringsEN.status_opened = "Online";
252+
StringsEN.status_closed = "Offline";
253+
StringsEN.status_error = "Error";
240254
//Teach-UI
241255
StringsEN.command = 'Command';
242256
StringsEN.chooseCommand = 'Please choose a command.';
@@ -259,6 +273,37 @@ function sepiaFW_build_strings(){
259273
StringsLocale.w = function(name){
260274
document.write(StringsLocale[name]);
261275
}
276+
277+
//-------------- Languages --------------
278+
279+
StringsLocale.getSupportedAppLanguages = function(){
280+
return [
281+
{value:"de", name:" DE "},
282+
{value:"en", name:" EN "},
283+
];
284+
}
285+
StringsLocale.getExperimentalAsrLanguages = function(){
286+
return [
287+
{value:"", name:"Default (app lang.)"},
288+
{value:"en-AU", name:"Australia (en-AU)"},
289+
{value:"en-CA", name:"Canada (en-CA)"},
290+
{value:"fr-FR", name:"France (fr-FR)"},
291+
{value:"el-GR", name:"Greece (el-GR)"},
292+
{value:"en-IE", name:"Ireland (en-IE)"},
293+
{value:"it-IT", name:"Italy (it-IT)"},
294+
{value:"ja-JP", name:"Japan (ja-JP)"},
295+
{value:"nl-NL", name:"Netherlands (nl-NL)"},
296+
{value:"en-NZ", name:"New Zealand (en-NZ)"},
297+
{value:"pt-PT", name:"Portugal (pt-PT)"},
298+
{value:"ru-RU", name:"Russia (ru-RU)"},
299+
{value:"en-ZA", name:"South Africa (en-ZA)"},
300+
{value:"af-ZA", name:"South Africa (af-ZA)"},
301+
{value:"es-ES", name:"Spain (es-ES)"},
302+
{value:"sv-SE", name:"Sweden (sv-SE)"},
303+
{value:"tr-TR", name:"Turkey (tr-TR)"},
304+
{value:"en-GB", name:"United Kingdom (en-GB)"}
305+
];
306+
}
262307

263308
return StringsLocale;
264309
}

www/scripts/sepiaFW.speech.js

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,38 @@ function sepiaFW_build_speech(){
66
//Parameters and states
77

88
//Common
9-
Speech.language = SepiaFW.config.appLanguage;
9+
var speechLanguage = SepiaFW.config.appLanguage;
10+
var speechCountryCode = "";
11+
Speech.getLanguage = function(){
12+
return speechLanguage;
13+
}
14+
Speech.setLanguage = function(newLang){
15+
speechLanguage = newLang;
16+
}
17+
Speech.setCountryCode = function(countryCode){
18+
speechCountryCode = countryCode;
19+
}
20+
//it might be necessary to use the long codes
21+
function getLongLanguageCode(langCodeShort){
22+
if (langCodeShort.length === 2){
23+
if (langCodeShort.toLowerCase() === "de"){
24+
return "de-DE";
25+
}else{
26+
return "en-US";
27+
}
28+
}
29+
}
30+
function getLanguageForASR(){
31+
if (speechCountryCode){
32+
return speechCountryCode;
33+
}else if (speechLanguage === "de"){
34+
return "de-DE";
35+
}else{
36+
return "en-US";
37+
}
38+
}
39+
Speech.getLongLanguageCode = getLongLanguageCode;
40+
Speech.getLanguageForASR = getLanguageForASR;
1041

1142
//ASR
1243
Speech.testAsrSupport = function(){
@@ -363,18 +394,6 @@ function sepiaFW_build_speech(){
363394
}
364395

365396
//----------helpers-----------
366-
367-
//it might be necessary to use the long codes
368-
function getLongLanguageCode(langCodeShort){
369-
if (langCodeShort.length === 2){
370-
if (langCodeShort.toLowerCase() === "de"){
371-
return "de-DE";
372-
}else{
373-
return "en-US";
374-
}
375-
}
376-
}
377-
Speech.getLongLanguageCode = getLongLanguageCode;
378397

379398
//auto stopping of speech recognition after a period of no results
380399
function autoStopASR(){
@@ -661,7 +680,7 @@ function sepiaFW_build_speech(){
661680
callback_interim(interim_transcript);
662681
};
663682

664-
recognition.lang = getLongLanguageCode(Speech.language);
683+
recognition.lang = getLanguageForASR();
665684
recognition.maxAlternatives = 1;
666685
recognition.start();
667686
}
@@ -770,7 +789,7 @@ function sepiaFW_build_speech(){
770789
if (selectedVoiceObject.name){
771790
$('#sepiaFW-menu-select-voice').val(selectedVoice);
772791
}
773-
SepiaFW.data.setPermanent(Speech.language + "-voice", selectedVoice);
792+
SepiaFW.data.setPermanent(Speech.getLanguage() + "-voice", selectedVoice);
774793
}
775794
}
776795
}
@@ -820,7 +839,7 @@ function sepiaFW_build_speech(){
820839
onTtsStart(event, startedCallback, errorCallback);
821840
TTS.speak({
822841
text: text,
823-
locale: getLongLanguageCode(Speech.language),
842+
locale: getLongLanguageCode(Speech.getLanguage()),
824843
rate: 1.00
825844

826845
}, function () {
@@ -839,7 +858,7 @@ function sepiaFW_build_speech(){
839858
window.sepia_tts_utterances = []; //This is a bug-fix to prevent utterance from getting garbage collected
840859
var utterance = new SpeechSynthesisUtterance();
841860
utterance.text = text;
842-
utterance.lang = getLongLanguageCode(Speech.language);
861+
utterance.lang = getLongLanguageCode(Speech.getLanguage());
843862
if (selectedVoice) utterance.voice = selectedVoiceObject;
844863
utterance.pitch = 1.0; //accepted values: 0-2 inclusive, default value: 1
845864
utterance.rate = 1.0; //accepted values: 0.1-10 inclusive, default value: 1
@@ -997,7 +1016,7 @@ function sepiaFW_build_speech(){
9971016
//set a preselected voice (e.g. in Edge)
9981017
function setVoiceOnce(){
9991018
//stored?
1000-
var storedVoice = SepiaFW.data.getPermanent(Speech.language + "-voice");
1019+
var storedVoice = SepiaFW.data.getPermanent(Speech.getLanguage() + "-voice");
10011020
if (storedVoice){
10021021
Speech.setVoice(storedVoice);
10031022

www/scripts/sepiaFW.speechWebSocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function sepiaFW_build_speechWebSocket(){
178178
//stopWebSocket();
179179
//Speech.stopRecording();
180180

181-
var language = SepiaFW.speech.getLongLanguageCode(SepiaFW.speech.language);
181+
var language = SepiaFW.speech.getLanguageForASR();
182182

183183
//WebSocket URI - TODO: handle parameters variable
184184
var uri = Speech.socketURI + ('?language=' + language);

www/scripts/sepiaFW.ui.build.js

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,40 @@ function sepiaFW_build_ui_build(){
1515
}
1616

1717
//build reuseable language selector
18-
Build.languageSelector = function(btnId, languageChangeAction){
18+
Build.optionSelector = function(btnId, optionsObjectArray, selectedValue, optionChangeAction){
1919
var ele = document.createElement("SELECT");
2020
if (btnId) ele.id = btnId;
21-
var code = ''
22-
+ '<option value="de">&nbsp;DE&nbsp;</option>'
23-
+ '<option value="en">&nbsp;EN&nbsp;</option>';
21+
var code = "";
22+
optionsObjectArray.forEach(function(option){
23+
code += '<option value="' + option.value + '">' + option.name + '</option>';
24+
});
2425
ele.innerHTML = code;
2526

27+
//initialize selected value
2628
for(var i, j = 0; i = ele.options[j]; j++) {
27-
if(i.value == SepiaFW.config.appLanguage) {
29+
if(i.value == selectedValue) {
2830
ele.selectedIndex = j;
2931
break;
3032
}
3133
}
32-
33-
$(ele).off();
34-
$(ele).on('change', function(){
35-
SepiaFW.config.broadcastLanguage(this.value);
36-
languageChangeAction(this.value);
34+
35+
//change listener
36+
$(ele).off().on('change', function(){
37+
if (optionChangeAction) optionChangeAction(ele);
3738
});
3839
return ele;
3940
}
41+
//build reuseable language selector
42+
Build.languageSelector = function(btnId, languageChangeAction){
43+
return Build.optionSelector(btnId,
44+
SepiaFW.local.getSupportedAppLanguages(),
45+
SepiaFW.config.appLanguage,
46+
function(ele){
47+
SepiaFW.config.broadcastLanguage(ele.value);
48+
languageChangeAction(ele.value);
49+
}
50+
);
51+
}
4052

4153
//toggle button
4254
Build.toggleButton = function(btnId, onCallback, offCallback, initialState){
@@ -510,21 +522,20 @@ function sepiaFW_build_ui_build(){
510522
centerPage2.innerHTML = ""
511523
+ "<ul class='sepiaFW-menu-settings-list'>"
512524
+ "<li id='sepiaFW-menu-select-skin-li'><span>Skin: </span><select id='sepiaFW-menu-select-skin'><option disabled selected value>- select -</option></select></li>"
525+
+ "<li id='sepiaFW-menu-assistant-host-li' title='Assistant hostname, e.g.: my.example.org/sepia, localhost or [IP]'>"
526+
+ "<span>Hostname: </span>"
527+
+ "<input id='sepiaFW-menu-assistant-host' type='url' placeholder='my.example.org/sepia' spellcheck='false'>"
528+
+ "</li>"
513529
+ "<li id='sepiaFW-menu-deviceId-li'><span>" + SepiaFW.local.g('deviceId') + ": </span><input id='sepiaFW-menu-deviceId' type='text' maxlength='24'></li>"
514530
+ "<li id='sepiaFW-menu-toggle-GPS-li'><span>GPS: </span></li>"
515531
+ "<li id='sepiaFW-menu-toggle-voice-li'><span>Voice output: </span></li>"
516532
+ "<li id='sepiaFW-menu-select-voice-li'><span>Voice: </span></li>" //option: <i class='material-icons md-mnu'>&#xE5C6;</i>
517533
+ "<li id='sepiaFW-menu-toggle-proactiveNotes-li' title='The assistant will remind you in a funny way to make a coffee break etc. :-)'><span>Well-being reminders: </span></li>"
518-
+ "<li id='sepiaFW-menu-clear-app-cache-li'><span>Clear app data: </span></li>"
519534
+ "<li id='sepiaFW-menu-toggle-channelMessages-li' title='Show status messages in chat like someone joined the channel?'><span>Channel status messages: </span></li>"
520535
//NOTE: we show this only if battery status API supported:
521536
+ "<li id='sepiaFW-menu-toggle-trackPowerStatus-li' title='Observe power plug and battery status?'><span>Track power status: </span></li>"
522537
//---
523538
+ "<li id='sepiaFW-menu-input-controls-li' title='Settings for remote input devices, e.g. gamepads'><span>Remote controls: </span></li>"
524-
+ "<li id='sepiaFW-menu-assistant-host-li' title='Assistant hostname, e.g.: my.example.org/sepia, localhost or [IP]'>"
525-
+ "<span>Hostname: </span>"
526-
+ "<input id='sepiaFW-menu-assistant-host' type='url' placeholder='my.example.org/sepia' spellcheck='false'>"
527-
+ "</li>"
528539
//Android-only background connect:
529540
+ "<li class='sepiaFW-android-settings' id='sepiaFW-menu-toggle-runBackgroundConnection-li' title='Try to keep connected in background?'><span>Allow background activity: </span></li>"
530541
//---
@@ -547,6 +558,13 @@ function sepiaFW_build_ui_build(){
547558
+ "<li id='sepiaFW-menu-select-music-app-li' title='Select default music app for search intents.'>"
548559
+ "<span>Default music app: </span></li>"
549560
//+ "<span id='sepiaFW-menu-toggle-music-cards-btn'><i class='material-icons'>art_track</i></span>"
561+
+ "<li id='sepiaFW-menu-clear-app-cache-li'><span>Clear app data: </span></li>"
562+
+ "<li id='sepiaFW-menu-experimental-settings-li'><span>Experimental settings </span></li>"
563+
+ "<li class='sepiaFW-menu-experimental'><span><u>Note: Changes will not be permanent</u></span></li>"
564+
+ "<li id='sepiaFW-menu-select-stt-language-li' class='sepiaFW-menu-experimental'><span>ASR country </span></li>"
565+
+ "<li id='sepiaFW-menu-toggle-youtube-wp-li' class='sepiaFW-menu-experimental'><span>YouTube embedded </span></li>"
566+
+ "<li id='sepiaFW-menu-toggle-spotify-wp-li' class='sepiaFW-menu-experimental'><span>Spotify embedded </span></li>"
567+
+ "<li id='sepiaFW-menu-toggle-apple-music-wp-li' class='sepiaFW-menu-experimental'><span>Apple Music embedded </span></li>"
550568
+ "<li id='sepiaFW-menu-administration-li'>"
551569
+ "<button id='sepiaFW-menu-ui-dataprivacy-btn'>" + SepiaFW.local.g('data_privacy') + "</button>"
552570
+ "<button id='sepiaFW-menu-ui-license-btn'>" + SepiaFW.local.g('license') + "</button>"
@@ -780,18 +798,7 @@ function sepiaFW_build_ui_build(){
780798
SepiaFW.ui.onShortLongPress($('#sepiaFW-menu-select-music-app-li').find('span').first()[0], function(){
781799
//Short press
782800
}, function(){
783-
//Long press
784-
if (SepiaFW.ui.cards.canEmbedSpotify){
785-
SepiaFW.ui.cards.canEmbedYouTube = false;
786-
SepiaFW.ui.cards.canEmbedSpotify = false;
787-
SepiaFW.ui.cards.canEmbedAppleMusic = false;
788-
SepiaFW.ui.showPopup("All music cards deactivated");
789-
}else{
790-
SepiaFW.ui.cards.canEmbedYouTube = true;
791-
SepiaFW.ui.cards.canEmbedSpotify = true;
792-
SepiaFW.ui.cards.canEmbedAppleMusic = true;
793-
SepiaFW.ui.showPopup("All music cards activated (for debugging)");
794-
}
801+
//Long press - this hidden setting moved to "experimental" below
795802
}, true);
796803
//$('#sepiaFW-menu-toggle-music-cards-btn').off().on('click', function(){});
797804

@@ -835,6 +842,42 @@ function sepiaFW_build_ui_build(){
835842
SepiaFW.debug.info("Proactive notes are deactivated");
836843
}, SepiaFW.assistant.isProActive)
837844
);
845+
//show/hide experimental settings
846+
document.getElementById('sepiaFW-menu-experimental-settings-li').appendChild(Build.inlineActionButton('sepiaFW-menu-experimental-settings', "Toggle",
847+
function(btn){
848+
$('.sepiaFW-menu-experimental').toggle(300);
849+
}
850+
));
851+
//ASR (STT) voice input language
852+
document.getElementById('sepiaFW-menu-select-stt-language-li').appendChild(Build.optionSelector('sepiaFW-menu-select-stt-language',
853+
SepiaFW.local.getExperimentalAsrLanguages(),
854+
"",
855+
function(ele){
856+
SepiaFW.speech.setCountryCode(ele.value);
857+
}
858+
));
859+
//Toggle embedded web-players
860+
document.getElementById('sepiaFW-menu-toggle-youtube-wp-li').appendChild(Build.toggleButton('sepiaFW-menu-toggle-youtube-wp',
861+
function(){
862+
SepiaFW.ui.cards.canEmbedYouTube = true;
863+
},function(){
864+
SepiaFW.ui.cards.canEmbedYouTube = false;
865+
}, SepiaFW.ui.cards.canEmbedYouTube)
866+
);
867+
document.getElementById('sepiaFW-menu-toggle-spotify-wp-li').appendChild(Build.toggleButton('sepiaFW-menu-toggle-spotify-wp',
868+
function(){
869+
SepiaFW.ui.cards.canEmbedSpotify = true;
870+
},function(){
871+
SepiaFW.ui.cards.canEmbedSpotify = false;
872+
}, SepiaFW.ui.cards.canEmbedSpotify)
873+
);
874+
document.getElementById('sepiaFW-menu-toggle-apple-music-wp-li').appendChild(Build.toggleButton('sepiaFW-menu-toggle-apple-music-wp',
875+
function(){
876+
SepiaFW.ui.cards.canEmbedAppleMusic = true;
877+
},function(){
878+
SepiaFW.ui.cards.canEmbedAppleMusic = false;
879+
}, SepiaFW.ui.cards.canEmbedAppleMusic)
880+
);
838881
//delete app cache
839882
document.getElementById('sepiaFW-menu-clear-app-cache-li').appendChild(Build.inlineActionButton('sepiaFW-menu-clear-app-cache', "Clear",
840883
function(btn){

0 commit comments

Comments
 (0)