diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-12 23:59:21 -0400 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-13 12:21:19 -0400 | 
| commit | 7bae3824e74461fbd5c9f66f921b05a47a40cbf4 (patch) | |
| tree | d0cdc8580497e447e05a31ab1e4806c4f325390b /ext/bg/js | |
| parent | 69b28571bdf8fb4c13198223e8a5668cf490840c (diff) | |
Add support for text-to-speech playback
Diffstat (limited to 'ext/bg/js')
| -rw-r--r-- | ext/bg/js/audio.js | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index 9508abf0..3efcce46 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -86,6 +86,24 @@ const audioUrlBuilders = {          throw new Error('Failed to find audio URL');      }, +    'text-to-speech': async (definition, optionsContext) => { +        const options = await apiOptionsGet(optionsContext); +        const voiceURI = options.audio.textToSpeechVoice; +        if (!voiceURI) { +            throw new Error('No voice'); +        } + +        return `tts:?text=${encodeURIComponent(definition.expression)}&voice=${encodeURIComponent(voiceURI)}`; +    }, +    'text-to-speech-reading': async (definition, optionsContext) => { +        const options = await apiOptionsGet(optionsContext); +        const voiceURI = options.audio.textToSpeechVoice; +        if (!voiceURI) { +            throw new Error('No voice'); +        } + +        return `tts:?text=${encodeURIComponent(definition.reading || definition.expression)}&voice=${encodeURIComponent(voiceURI)}`; +    },      'custom': async (definition, optionsContext) => {          const options = await apiOptionsGet(optionsContext);          const customSourceUrl = options.audio.customSourceUrl; |