Skip to content

Commit 362b211

Browse files
author
botium-build
committed
BOT-2003 use javascript to get dictate.js urls
1 parent 7ad1a96 commit 362b211

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

Diff for: dictate/.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
dictate.js
2+
dictate.js-master

Diff for: dictate/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
package-lock.json
33
*.local
4-
dictate.js
4+
dictate.js-master

Diff for: dictate/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "Unified Speech Processing",
55
"scripts": {
6+
"prepare": "rm -rf ./dictate.js-master && curl -L -o dicatejs.zip \"https://github.com/Kaljurand/dictate.js/archive/master.zip\" && unzip dicatejs.zip && rm dicatejs.zip",
67
"start": "node server.js"
78
},
89
"author": "Botium GmbH",

Diff for: dictate/server.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@ const fs = require('fs')
22
const express = require('express')
33

44
const app = express()
5-
app.disable('etag')
6-
app.set('trust proxy', true)
75
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+
`
918

1019
app.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')

Diff for: docker-compose.override.template.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@ version: '3'
22
services:
33
frontend:
44
environment:
5-
BOTIUM_SPEECH_URL: https://speech.botiumbox.com
6-
dictate:
7-
image: botium/botium-speech-dictate:develop
8-
environment:
9-
STT_URL_DE: wss://speech.botiumbox.com/stt-de
10-
STT_URL_EN: wss://speech.botiumbox.com/stt-en
5+
BOTIUM_SPEECH_URL: https://speech.botiumbox.com

0 commit comments

Comments
 (0)