diff options
Diffstat (limited to 'ext/bg')
| -rw-r--r-- | ext/bg/js/audio.js | 18 | ||||
| -rw-r--r-- | ext/bg/settings.html | 4 | 
2 files changed, 21 insertions, 1 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; diff --git a/ext/bg/settings.html b/ext/bg/settings.html index ffa5533e..15425b44 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -319,8 +319,10 @@                          <div class="input-group-addon audio-source-prefix"></div>                          <select class="form-control audio-source-select">                              <option value="jpod101">JapanesePod101</option> -                            <option value="jpod101-alternate">JapanesePod101 (alternate)</option> +                            <option value="jpod101-alternate">JapanesePod101 (Alternate)</option>                              <option value="jisho">Jisho.org</option> +                            <option value="text-to-speech">Text-to-speech</option> +                            <option value="text-to-speech-reading">Text-to-speech (Kana reading)</option>                              <option value="custom">Custom</option>                          </select>                          <div class="input-group-btn"><button class="btn btn-danger audio-source-remove" title="Remove"><span class="glyphicon glyphicon-remove"></span></button></div> |