Skip to content

Commit f036af0

Browse files
committed
added more debug/help info for insecure-origin issues (mic access etc.);
1 parent 9e6ac67 commit f036af0

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

www/scripts/sepiaFW.audioRecorder.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ function sepiaFW_build_audio_recorder(){
3838
var isCordovaAudioinputSupported = undefined;
3939

4040
function testStreamRecorderSupport(){
41-
isMediaDevicesSupported = !!AudioContext
42-
&& ((navigator.mediaDevices && navigator.mediaDevices.getUserMedia)
43-
|| navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
41+
isMediaDevicesSupported = !!AudioContext && (
42+
(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) ||
43+
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia
44+
);
4445
isCordovaAudioinputSupported = (window.cordova && window.audioinput);
4546
return !!isMediaDevicesSupported || isCordovaAudioinputSupported;
4647
}

www/scripts/sepiaFW.local.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function sepiaFW_build_strings(){
131131
StringsDE.cant_execute = "Sorry, aber es sieht so aus als könnte ich diese Aktion nicht ausführen.";
132132
StringsDE.tried_but_not_sure = "Hab's versucht aber bin nicht sicher ob es geklappt hat.";
133133
StringsDE.result_unclear = "Das Ergebnis der folgenden Anfrage ist unklar.";
134+
StringsDE.possible_reason_origin_unsecure = "Mögliche Ursache: Unsicherer Ursprung (SSL Zertifikat)";
134135
//Service and action texts
135136
StringsDE.opening_link = "Link wird geöffnet.";
136137
StringsDE.no_music_playing = "Kannst du was hören? Wahrscheinlich wurde keine Musik gefunden.";
@@ -283,6 +284,7 @@ function sepiaFW_build_strings(){
283284
StringsEN.cant_execute = "Sorry, but it seems I can't execute the requested action.";
284285
StringsEN.tried_but_not_sure = "I've tried but I'm not sure if it worked.";
285286
StringsEN.result_unclear = "The result of the following request is unclear.";
287+
StringsEN.possible_reason_origin_unsecure = "Possible reason: Unsecure origin (SSL certificate)";
286288
//Service and action texts
287289
StringsEN.opening_link = "Opening link.";
288290
StringsEN.no_music_playing = "Can you hear something? Probably no music found.";

www/scripts/sepiaFW.speech.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,13 @@ function sepiaFW_build_speech(){
349349
function broadcastNoAsrSupport(){
350350
//EXAMPLE:
351351
SepiaFW.animate.assistant.idle('asrNoSupport');
352-
SepiaFW.ui.showInfo(SepiaFW.local.g('noAsrSupport'));
352+
var msg = SepiaFW.local.g('noAsrSupport');
353+
if (!SepiaFW.ui.isSecureContext){
354+
msg += " " + SepiaFW.local.g('possible_reason_origin_unsecure')
355+
+ " - <a href='https://github.com/SEPIA-Framework/sepia-docs/wiki/SSL-for-your-Server' target=_blank style='color: inherit;'>"
356+
+ SepiaFW.local.g('help') + "!</a>";
357+
}
358+
SepiaFW.ui.showInfo(msg);
353359
}
354360

355361
//TTS

www/scripts/sepiaFW.speechWebSocket.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ function sepiaFW_build_speechWebSocket(){
7575
function broadcastNoAsrSupport(){
7676
//EXAMPLE:
7777
SepiaFW.animate.assistant.idle('asrNoSupport');
78-
SepiaFW.ui.showInfo(SepiaFW.local.g('noAsrSupport'));
78+
var msg = SepiaFW.local.g('noAsrSupport');
79+
if (!SepiaFW.ui.isSecureContext){
80+
msg += " " + SepiaFW.local.g('possible_reason_origin_unsecure')
81+
+ " - <a href='https://github.com/SEPIA-Framework/sepia-docs/wiki/SSL-for-your-Server' target=_blank style='color: inherit;'>"
82+
+ SepiaFW.local.g('help') + "!</a>";
83+
}
84+
SepiaFW.ui.showInfo(msg);
7985
}
8086
function broadcastMissingServerInfo(){
8187
//EXAMPLE:

www/scripts/sepiaFW.ui.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ function sepiaFW_build_ui(){
2121
UI.isSafari = false;
2222
UI.isEdge = false;
2323

24+
UI.isSecureContext = UI.isCordova? true : (('isSecureContext' in window)? window.isSecureContext : (window.location.protocol == "https:"));
25+
2426
UI.getPreferredColorScheme = function(){
2527
if ('matchMedia' in window){
2628
if (window.matchMedia('(prefers-color-scheme: dark)').matches){

www/scripts/sepiaFW.wakeWordSettings.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ function sepiaFW_build_wake_word_settings() {
2424
}
2525
}
2626

27-
WakeWordSettings.debugLog = function(info){
28-
if (debugInfo){
29-
$('#sepiaFW-wake-word-audio-info').append(info + "<br>");
27+
WakeWordSettings.debugLog = function(info, isError){
28+
if (debugInfo || isError){
29+
if (isError){
30+
$('#sepiaFW-wake-word-audio-info').append("<span style='color: #ff0000;'>" + info + "</span><br>");
31+
}else{
32+
$('#sepiaFW-wake-word-audio-info').append(info + "<br>");
33+
}
3034
console.log(info);
3135
}
3236
}
@@ -130,6 +134,10 @@ function sepiaFW_build_wake_word_settings() {
130134
}
131135
});
132136
});
137+
138+
if (!SepiaFW.ui.isSecureContext){
139+
WakeWordSettings.debugLog("Please note: The browser thinks your page origin is NOT secure! Speech recognition might not work properly.", true);
140+
}
133141
}
134142

135143
//ON-OPEN

0 commit comments

Comments
 (0)