@internetarchive/bookreader 5.0.0-51 → 5.0.0-52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BookReader/BookReader.js +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/CHANGELOG.md +3 -2
- package/package.json +1 -1
- package/src/plugins/tts/WebTTSEngine.js +21 -2
- package/src/util/manifestGenerator.js +0 -0
- package/tests/jest/plugins/tts/WebTTSEngine.test.js +47 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
# 5.0.0-52
|
|
1
2
|
# 5.0.0-51
|
|
2
|
-
- Fix: Bookmark with subfiles was broken
|
|
3
|
-
- Feature: Default 1up mode and options.defaults mode override exiting mode
|
|
3
|
+
- Fix: Bookmark with subfiles was broken @nsharma123
|
|
4
|
+
- Feature: Default 1up mode and options.defaults mode override exiting mode @nsharma123
|
|
4
5
|
|
|
5
6
|
# 5.0.0-50
|
|
6
7
|
Fix: Search results display @latonv
|
package/package.json
CHANGED
|
@@ -71,7 +71,22 @@ export default class WebTTSEngine extends AbstractTTSEngine {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** @override */
|
|
74
|
-
getVoices() {
|
|
74
|
+
getVoices() {
|
|
75
|
+
const voices = speechSynthesis.getVoices();
|
|
76
|
+
if (voices.filter(v => v.default).length != 1) {
|
|
77
|
+
// iOS bug where the default system voice is sometimes
|
|
78
|
+
// missing from the list
|
|
79
|
+
voices.unshift({
|
|
80
|
+
voiceURI: 'bookreader.SystemDefault',
|
|
81
|
+
name: 'System Default',
|
|
82
|
+
// Not necessarily true, but very likely
|
|
83
|
+
lang: navigator.language,
|
|
84
|
+
default: true,
|
|
85
|
+
localService: true,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return voices;
|
|
89
|
+
}
|
|
75
90
|
|
|
76
91
|
/** @override */
|
|
77
92
|
createSound(chunk) {
|
|
@@ -122,7 +137,11 @@ export class WebTTSSound {
|
|
|
122
137
|
this.started = false;
|
|
123
138
|
|
|
124
139
|
this.utterance = new SpeechSynthesisUtterance(this.text.slice(this._charIndex));
|
|
125
|
-
|
|
140
|
+
// iOS bug where the default system voice is sometimes
|
|
141
|
+
// missing from the list
|
|
142
|
+
if (this.voice?.voiceURI !== 'bookreader.SystemDefault') {
|
|
143
|
+
this.utterance.voice = this.voice;
|
|
144
|
+
}
|
|
126
145
|
// Need to also set lang (for some reason); won't set voice on Chrome@Android otherwise
|
|
127
146
|
if (this.voice) this.utterance.lang = this.voice.lang;
|
|
128
147
|
this.utterance.rate = this.rate;
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import sinon from 'sinon';
|
|
2
|
-
import { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js';
|
|
2
|
+
import WebTTSEngine, { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js';
|
|
3
3
|
import { afterEventLoop, eventTargetMixin } from '../../utils.js';
|
|
4
4
|
|
|
5
5
|
beforeEach(() => {
|
|
@@ -8,6 +8,7 @@ beforeEach(() => {
|
|
|
8
8
|
speak: sinon.stub(),
|
|
9
9
|
pause: sinon.stub(),
|
|
10
10
|
resume: sinon.stub(),
|
|
11
|
+
|
|
11
12
|
...eventTargetMixin(),
|
|
12
13
|
};
|
|
13
14
|
window.SpeechSynthesisUtterance = function (text) {
|
|
@@ -21,6 +22,51 @@ afterEach(() => {
|
|
|
21
22
|
delete window.SpeechSynthesisUtterance;
|
|
22
23
|
});
|
|
23
24
|
|
|
25
|
+
describe('WebTTSEngine', () => {
|
|
26
|
+
test('getVoices should include default voice when no actual default', () => {
|
|
27
|
+
// iOS devices set all the voices to default -_-
|
|
28
|
+
speechSynthesis.getVoices = () => [
|
|
29
|
+
{
|
|
30
|
+
default: true,
|
|
31
|
+
lang: "ar-001",
|
|
32
|
+
localService: true,
|
|
33
|
+
name: "Majed",
|
|
34
|
+
voiceURI: "com.apple.voice.compact.ar-001.Maged",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
default: true,
|
|
38
|
+
lang: "bg-BG",
|
|
39
|
+
localService: true,
|
|
40
|
+
name: "Daria",
|
|
41
|
+
voiceURI: "com.apple.voice.compact.bg-BG.Daria",
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
const voices = WebTTSEngine.prototype.getVoices();
|
|
45
|
+
expect(voices.length).toBe(3);
|
|
46
|
+
expect(voices[0].voiceURI).toBe('bookreader.SystemDefault');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('getVoices should not include default voice when there is a default', () => {
|
|
50
|
+
speechSynthesis.getVoices = () => [
|
|
51
|
+
{
|
|
52
|
+
default: true,
|
|
53
|
+
lang: "ar-001",
|
|
54
|
+
localService: true,
|
|
55
|
+
name: "Majed",
|
|
56
|
+
voiceURI: "com.apple.voice.compact.ar-001.Maged",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
default: false,
|
|
60
|
+
lang: "bg-BG",
|
|
61
|
+
localService: true,
|
|
62
|
+
name: "Daria",
|
|
63
|
+
voiceURI: "com.apple.voice.compact.bg-BG.Daria",
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
const voices = WebTTSEngine.prototype.getVoices();
|
|
67
|
+
expect(voices.length).toBe(2);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
24
70
|
|
|
25
71
|
describe('WebTTSSound', () => {
|
|
26
72
|
describe('setPlaybackRate', () => {
|