Skip to content

Commit

Permalink
Workaround for issue where Firefox can offer excessive numbers of TTS…
Browse files Browse the repository at this point in the history
… voices causing slowdown.
  • Loading branch information
Lattyware committed Sep 8, 2020
1 parent 54c4c16 commit 5d37ea0
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 99 deletions.
2 changes: 1 addition & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /md

COPY ["./package.json", "./package-lock.json", "./"]

RUN ["apk", "add", "--no-cache", "--virtual", ".gyp", "python", "make", "g++"]
RUN ["apk", "add", "--no-cache", "--virtual", ".gyp", "python", "make", "g++", "openjdk8-jre"]
RUN ["npm", "ci"]

COPY ["./tsconfig.json", "postcss.config.js", "./webpack.config.js", "./elm.json", "./"]
Expand Down
230 changes: 188 additions & 42 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"closure-webpack-plugin": "^2.3.0",
"compression-webpack-plugin": "^5.0.2",
"css-hot-loader": "^1.4.4",
"css-loader": "^4.2.2",
"css-loader": "^4.3.0",
"cssnano": "^4.1.10",
"elm": "^0.19.1-3",
"elm-analyse": "^0.16.5",
Expand All @@ -64,7 +64,7 @@
"html-loader": "^1.3.0",
"html-webpack-plugin": "^4.4.1",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-loader": "^4.0.1",
"postcss-preset-env": "^6.7.0",
"prettier": "2.1.1",
"prettier-plugin-elm": "^0.7.0",
Expand Down
9 changes: 5 additions & 4 deletions client/src/ts/speech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,25 @@ class Speech {
this.out = out;
this.get_voices();

inbound.subscribe(command => {
inbound.subscribe((command) => {
this.say(command.voice, command.phrase);
});

this.speech.addEventListener("voiceschanged", () => this.get_voices());
}

get_voices(): void {
const voices = this.speech.getVoices();
// The slice is a sanity check, Firefox can get pathological with voices.
const voices = this.speech.getVoices().slice(0, 100);
this.voices.clear();
for (const voice of voices) {
this.voices.set(voice.name, voice);
}
this.out.send(
voices.map(voice => ({
voices.map((voice) => ({
name: voice.name,
lang: voice.lang,
...(voice.default ? { default: true } : {})
...(voice.default ? { default: true } : {}),
}))
);
}
Expand Down
Loading

0 comments on commit 5d37ea0

Please sign in to comment.