Skip to content

Commit

Permalink
Merge pull request #353 from stephen-soltesz/add-studio
Browse files Browse the repository at this point in the history
Add checkbox to enable Google Studio voices
  • Loading branch information
ken107 authored Oct 31, 2023
2 parents dfb01f0 + 4b8a455 commit 95abf4e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
6 changes: 6 additions & 0 deletions custom-voices.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ <h3 class="mt-3">Enable Custom Voices</h3>
<button type="button" class="btn btn-primary" id="gcp-save-button">Save</button>
</div>
</div>
<br/>
<div class="input-group">
<label for="gcp-enable-studio">
<input type="checkbox" id="gcp-enable-studio" name="gcp-enable-studio" value="enabled">
Include Google Studio voices. (WARNING: 10x cost)</label>
</div>
</div>
<div class="form-group">
<img id="gcp-progress" class="status progress" src="img/loading.gif" />
Expand Down
10 changes: 8 additions & 2 deletions js/custom-voices.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $(function() {
}
if (items.gcpCreds) {
$("#gcp-api-key").val(obfuscate(items.gcpCreds.apiKey));
$("#gcp-enable-studio").prop('checked', items.gcpCreds.enableStudio);
}
if (items.ibmCreds) {
$("#ibm-api-key").val(obfuscate(items.ibmCreds.apiKey));
Expand Down Expand Up @@ -74,13 +75,18 @@ function testAws(accessKeyId, secretAccessKey) {
function gcpSave() {
$(".status").hide();
var apiKey = $("#gcp-api-key").val().trim();
var enableStudio = $("#gcp-enable-studio").is(':checked');
if (apiKey) {
$("#gcp-progress").show();
testGcp(apiKey)
.then(function() {
$("#gcp-progress").hide();
updateSettings({gcpCreds: {apiKey: apiKey}});
$("#gcp-success").text("Google Wavenet voices are enabled.").show();
updateSettings({gcpCreds: {apiKey: apiKey, enableStudio: enableStudio}});
if (enableStudio) {
$("#gcp-success").text("Google Wavenet & Studio voices are enabled.").show();
} else {
$("#gcp-success").text("Google Wavenet voices are enabled.").show();
}
$("#gcp-api-key").val(obfuscate(apiKey));
},
function(err) {
Expand Down
6 changes: 5 additions & 1 deletion js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ function isAmazonPolly(voice) {
}

function isGoogleWavenet(voice) {
return /^Google(Standard|Wavenet|Neural2) /.test(voice.voiceName);
return /^Google(Standard|Wavenet|Neural2|Studio) /.test(voice.voiceName);
}

function isGoogleStudio(voice) {
return /^Google(Studio) /.test(voice.voiceName);
}

function isIbmWatson(voice) {
Expand Down
15 changes: 12 additions & 3 deletions js/tts-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,16 @@ function GoogleWavenetTtsEngine() {
this.setNextStartTime = function() {
};
this.getVoices = function() {
return getSettings(["wavenetVoices"])
return getSettings(["wavenetVoices", "gcpCreds"])
.then(function(items) {
if (!items.wavenetVoices || Date.now()-items.wavenetVoices[0].ts > 24*3600*1000) updateVoices();
return items.wavenetVoices || voices;
var listvoices = items.wavenetVoices || voices;
var creds = items.gcpCreds;
return listvoices.filter(
function(voice) {
// include all voices or exclude only studio voices.
return ((creds && creds.enableStudio) || !isGoogleStudio(voice));
});
})
}
this.getFreeVoices = function() {
Expand Down Expand Up @@ -1014,7 +1020,10 @@ function GoogleWavenetTtsEngine() {
{"voiceName":"GoogleStandard French (Daniel)","lang":"fr-FR","gender":"male"},
{"voiceName":"GoogleStandard Italian (Bianca)","lang":"it-IT","gender":"female"},
{"voiceName":"GoogleStandard Italian (Christopher)","lang":"it-IT","gender":"male"},
{"voiceName":"GoogleStandard Italian (Daniel)","lang":"it-IT","gender":"male"}
{"voiceName":"GoogleStandard Italian (Daniel)","lang":"it-IT","gender":"male"},
{"voiceName":"GoogleStudio US English (M)","lang":"en-US","gender":"male"},
{"voiceName":"GoogleStudio US English (O)","lang":"en-US","gender":"female"},
{"voiceName":"GoogleStudio US English (Q)","lang":"en-US","gender":"male"}
]
}

Expand Down

0 comments on commit 95abf4e

Please sign in to comment.