Remove de/structuring from public API

This commit is contained in:
toasted-nutbread 2020-04-10 13:51:47 -04:00
parent 7fc3882607
commit 823c026533
2 changed files with 4 additions and 3 deletions

View File

@ -110,7 +110,7 @@ function textToSpeechTest() {
const text = document.querySelector('#text-to-speech-voice-test').dataset.speechText || ''; const text = document.querySelector('#text-to-speech-voice-test').dataset.speechText || '';
const voiceUri = document.querySelector('#text-to-speech-voice').value; const voiceUri = document.querySelector('#text-to-speech-voice').value;
const audio = audioSystem.createTextToSpeechAudio({text, voiceUri}); const audio = audioSystem.createTextToSpeechAudio(text, voiceUri);
audio.volume = 1.0; audio.volume = 1.0;
audio.play(); audio.play();
} catch (e) { } catch (e) {

View File

@ -102,7 +102,7 @@ class AudioSystem {
throw new Error('Could not create audio'); throw new Error('Could not create audio');
} }
createTextToSpeechAudio({text, voiceUri}) { createTextToSpeechAudio(text, voiceUri) {
const voice = this._getTextToSpeechVoiceFromVoiceUri(voiceUri); const voice = this._getTextToSpeechVoiceFromVoiceUri(voiceUri);
if (voice === null) { if (voice === null) {
throw new Error('Invalid text-to-speech voice'); throw new Error('Invalid text-to-speech voice');
@ -117,7 +117,8 @@ class AudioSystem {
async _createAudio(uri) { async _createAudio(uri) {
const ttsParameters = this._getTextToSpeechParameters(uri); const ttsParameters = this._getTextToSpeechParameters(uri);
if (ttsParameters !== null) { if (ttsParameters !== null) {
return this.createTextToSpeechAudio(ttsParameters); const {text, voiceUri} = ttsParameters;
return this.createTextToSpeechAudio(text, voiceUri);
} }
return await this._createAudioFromUrl(uri); return await this._createAudioFromUrl(uri);