Skip to content

Commit eab002f

Browse files
committed
hide speech-dispatcher voices, allow enable via Custom Voices
1 parent dd104f5 commit eab002f

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

custom-voices.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ <h3 class="mt-3">Enable Custom Voices</h3>
143143

144144
<div class="col-lg-6">
145145
<div class="card border-primary openai">
146-
<div class="card-header card-header-dark">
146+
<div class="card-header">
147147
OpenAI
148148
<div class="subtext">Use OpenAI or an OpenAI-compatible Speech endpoint</div>
149149
</div>
@@ -196,6 +196,23 @@ <h3 class="mt-3">Enable Custom Voices</h3>
196196
</div>
197197
</div>
198198
</div>
199+
200+
<div class="col-lg-6" id="speechd-panel">
201+
<div class="card border-primary">
202+
<div class="card-header">
203+
Speech-dispatcher (Linux OS)
204+
<div class="subtext">Speech-dispatcher voices are hidden because by default they rely on eSpeak NG, which has very poor voice quality.</div>
205+
</div>
206+
<div class="card-body view-new">
207+
<div class="form-group">
208+
<div class="form-check">
209+
<input class="form-check-input" type="checkbox" id="speechd-toggle">
210+
<label class="form-check-label" for="speechd-toggle">Show speech-dispatcher voices</label>
211+
</div>
212+
</div>
213+
</div>
214+
</div>
215+
</div>
199216
</div>
200217

201218
</div>

js/custom-voices.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11

2+
Promise.all([
3+
browserTtsEngine.getVoices().then(voices => voices.some(isSpeechDispatcher)),
4+
getSetting('useSpeechDispatcher').then(b => !!b),
5+
domReady()
6+
]).then(([hasSpeechdVoices, useSpeechd]) => {
7+
$("#speechd-panel").toggle(hasSpeechdVoices || useSpeechd)
8+
$("#speechd-toggle").prop("checked", useSpeechd)
9+
.change(function() {
10+
updateSetting("useSpeechDispatcher", this.checked)
11+
})
12+
})
13+
14+
215
$(function() {
316
getSettings(["awsCreds", "gcpCreds", "ibmCreds", "azureCreds"])
417
.then(function(items) {

js/defaults.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,14 @@ const voices$ = rxjs.combineLatest({
517517
azureCreds: observeSetting("azureCreds"),
518518
piperVoices: observeSetting("piperVoices"),
519519
supertonicVoices: observeSetting("supertonicVoices"),
520+
useSpeechDispatcher: observeSetting("useSpeechDispatcher"),
520521
}).pipe(
521522
rxjs.exhaustMap(settings => Promise.all([
522-
browserTtsEngine.getVoices(),
523+
browserTtsEngine.getVoices().then(voices =>
524+
settings.useSpeechDispatcher
525+
? voices
526+
: voices.filter(voice => !isSpeechDispatcher(voice))
527+
),
523528
googleTranslateTtsEngine.getVoices(),
524529
premiumTtsEngine.getVoices(),
525530
settings.awsCreds ? amazonPollyTtsEngine.getVoices() : [],
@@ -545,6 +550,10 @@ function isOfflineVoice(voice) {
545550
return voice.localService == true
546551
}
547552

553+
function isSpeechDispatcher(voice) {
554+
return /:speechd:/.test(voice.voiceURI)
555+
}
556+
548557
function isChromeOSNative(voice) {
549558
return /^Chrome\sOS\s/.test(voice.voiceName);
550559
}

0 commit comments

Comments
 (0)