@@ -2,25 +2,26 @@ const fs = require('fs')
22const express = require ( 'express' )
33
44const app = express ( )
5- app . disable ( 'etag' )
6- app . set ( 'trust proxy' , true )
75const 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+ `
918
1019app . get ( '/demos/mob.html' , ( req , res ) => {
1120 let mobHtml = fs . readFileSync ( `${ dictateDir } /demos/mob.html` , { encoding : 'utf-8' } )
1221
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- )
2122 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 >`
2425 )
2526
2627 res . header ( 'Content-Type' , 'text/html' )
0 commit comments