aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 14:10:43 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 21:43:51 -0500
commita8eb50d96f50ae20033ccc05094caaedbae81936 (patch)
tree21e603c0a8986301dab7d3ad0522153de232ed0a /ext/mixed/js/audio.js
parent75eac153d625c54892a6f7194d0cfa4160ffe722 (diff)
Use dependency injection for getAudioUri implementation
Diffstat (limited to 'ext/mixed/js/audio.js')
-rw-r--r--ext/mixed/js/audio.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js
index d2feae04..1da5d48c 100644
--- a/ext/mixed/js/audio.js
+++ b/ext/mixed/js/audio.js
@@ -16,8 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-/*global apiAudioGetUrl*/
-
class TextToSpeechAudio {
constructor(text, voice) {
this.text = text;
@@ -69,9 +67,10 @@ class TextToSpeechAudio {
}
class AudioSystem {
- constructor() {
+ constructor({getAudioUri}) {
this._cache = new Map();
this._cacheSizeMaximum = 32;
+ this._getAudioUri = getAudioUri;
if (typeof speechSynthesis !== 'undefined') {
// speechSynthesis.getVoices() will not be populated unless some API call is made.
@@ -79,7 +78,7 @@ class AudioSystem {
}
}
- async getExpressionAudio(expression, sources, optionsContext, details) {
+ async getExpressionAudio(expression, sources, details) {
const key = `${expression.expression}:${expression.reading}`;
const cacheValue = this._cache.get(expression);
if (typeof cacheValue !== 'undefined') {
@@ -88,7 +87,7 @@ class AudioSystem {
}
for (const source of sources) {
- const uri = await apiAudioGetUrl(expression, source, optionsContext);
+ const uri = await this._getAudioUri(expression, source, details);
if (uri === null) { continue; }
try {