@@ -2,25 +2,26 @@ const fs = require('fs')
2
2
const express = require ( 'express' )
3
3
4
4
const app = express ( )
5
- app . disable ( 'etag' )
6
- app . set ( 'trust proxy' , true )
7
5
const port = process . env . PORT || 56100
8
- const dictateDir = process . env . DICTATEDIR || './dictate.js'
6
+ const dictateDir = process . env . DICTATEDIR || './dictate.js-master'
7
+
8
+ const wsScript = `
9
+ var sttUrlDe = new URL('/stt-de', window.location.href);
10
+ sttUrlDe.protocol = sttUrlDe.protocol.replace('http', 'ws');
11
+ var sttUrlEn = new URL('/stt-en', window.location.href);
12
+ sttUrlEn.protocol = sttUrlEn.protocol.replace('http', 'ws');
13
+
14
+ var serversElement = document.getElementById('servers')
15
+ serversElement.options[0] = new Option("English", sttUrlEn.href + "/client/ws/speech|" + sttUrlEn.href + "/client/ws/status", true, false)
16
+ serversElement.options[1] = new Option("German", sttUrlDe.href + "/client/ws/speech|" + sttUrlDe.href + "/client/ws/status", false, false)
17
+ `
9
18
10
19
app . get ( '/demos/mob.html' , ( req , res ) => {
11
20
let mobHtml = fs . readFileSync ( `${ dictateDir } /demos/mob.html` , { encoding : 'utf-8' } )
12
21
13
- const wsProtocol = ( req . protocol === 'https' ? 'wss:' : 'ws:' )
14
- const sttUrlDe = process . env . STT_URL_DE || `${ wsProtocol } //${ req . hostname } /stt-de`
15
- const sttUrlEn = process . env . STT_URL_EN || `${ wsProtocol } //${ req . hostname } /stt-en`
16
-
17
- mobHtml = mobHtml . replace (
18
- '<option value="wss://bark.phon.ioc.ee:8443/dev/duplex-speech-api/ws/speech|wss://bark.phon.ioc.ee:8443/dev/duplex-speech-api/ws/status">eesti keel</option>' ,
19
- `<option value="${ sttUrlDe } /client/ws/speech|${ sttUrlDe } /client/ws/status">German</option>`
20
- )
21
22
mobHtml = mobHtml . replace (
22
- '<option value="wss://bark.phon.ioc.ee:8443/english/duplex-speech-api/ws/speech|wss://bark.phon.ioc.ee:8443/english/duplex-speech-api/ws/status" selected="selected">English</option >' ,
23
- `<option value=" ${ sttUrlEn } /client/ws/speech| ${ sttUrlEn } /client/ws/status" selected="selected">English</option >`
23
+ '<script src="mob.js"></script >' ,
24
+ `<script src="mob.js"></script><script> ${ wsScript } </script >`
24
25
)
25
26
26
27
res . header ( 'Content-Type' , 'text/html' )
0 commit comments