@internetarchive/bookreader
Advanced tools
Comparing version 5.0.0-51 to 5.0.0-52
@@ -0,4 +1,5 @@ | ||
# 5.0.0-52 | ||
# 5.0.0-51 | ||
- Fix: Bookmark with subfiles was broken | ||
- Feature: Default 1up mode and options.defaults mode override exiting mode | ||
- Fix: Bookmark with subfiles was broken @nsharma123 | ||
- Feature: Default 1up mode and options.defaults mode override exiting mode @nsharma123 | ||
@@ -5,0 +6,0 @@ # 5.0.0-50 |
{ | ||
"name": "@internetarchive/bookreader", | ||
"version": "5.0.0-51", | ||
"version": "5.0.0-52", | ||
"description": "The Internet Archive BookReader.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -74,3 +74,18 @@ /* global br */ | ||
/** @override */ | ||
getVoices() { return speechSynthesis.getVoices(); } | ||
getVoices() { | ||
const voices = speechSynthesis.getVoices(); | ||
if (voices.filter(v => v.default).length != 1) { | ||
// iOS bug where the default system voice is sometimes | ||
// missing from the list | ||
voices.unshift({ | ||
voiceURI: 'bookreader.SystemDefault', | ||
name: 'System Default', | ||
// Not necessarily true, but very likely | ||
lang: navigator.language, | ||
default: true, | ||
localService: true, | ||
}); | ||
} | ||
return voices; | ||
} | ||
@@ -126,3 +141,7 @@ /** @override */ | ||
this.utterance = new SpeechSynthesisUtterance(this.text.slice(this._charIndex)); | ||
this.utterance.voice = this.voice; | ||
// iOS bug where the default system voice is sometimes | ||
// missing from the list | ||
if (this.voice?.voiceURI !== 'bookreader.SystemDefault') { | ||
this.utterance.voice = this.voice; | ||
} | ||
// Need to also set lang (for some reason); won't set voice on Chrome@Android otherwise | ||
@@ -129,0 +148,0 @@ if (this.voice) this.utterance.lang = this.voice.lang; |
import sinon from 'sinon'; | ||
import { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js'; | ||
import WebTTSEngine, { WebTTSSound } from '@/src/plugins/tts/WebTTSEngine.js'; | ||
import { afterEventLoop, eventTargetMixin } from '../../utils.js'; | ||
@@ -11,2 +11,3 @@ | ||
resume: sinon.stub(), | ||
...eventTargetMixin(), | ||
@@ -25,3 +26,48 @@ }; | ||
describe('WebTTSEngine', () => { | ||
test('getVoices should include default voice when no actual default', () => { | ||
// iOS devices set all the voices to default -_- | ||
speechSynthesis.getVoices = () => [ | ||
{ | ||
default: true, | ||
lang: "ar-001", | ||
localService: true, | ||
name: "Majed", | ||
voiceURI: "com.apple.voice.compact.ar-001.Maged", | ||
}, | ||
{ | ||
default: true, | ||
lang: "bg-BG", | ||
localService: true, | ||
name: "Daria", | ||
voiceURI: "com.apple.voice.compact.bg-BG.Daria", | ||
} | ||
]; | ||
const voices = WebTTSEngine.prototype.getVoices(); | ||
expect(voices.length).toBe(3); | ||
expect(voices[0].voiceURI).toBe('bookreader.SystemDefault'); | ||
}); | ||
test('getVoices should not include default voice when there is a default', () => { | ||
speechSynthesis.getVoices = () => [ | ||
{ | ||
default: true, | ||
lang: "ar-001", | ||
localService: true, | ||
name: "Majed", | ||
voiceURI: "com.apple.voice.compact.ar-001.Maged", | ||
}, | ||
{ | ||
default: false, | ||
lang: "bg-BG", | ||
localService: true, | ||
name: "Daria", | ||
voiceURI: "com.apple.voice.compact.bg-BG.Daria", | ||
} | ||
]; | ||
const voices = WebTTSEngine.prototype.getVoices(); | ||
expect(voices.length).toBe(2); | ||
}); | ||
}); | ||
describe('WebTTSSound', () => { | ||
@@ -28,0 +74,0 @@ describe('setPlaybackRate', () => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
8984236
439
28593