aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/audio.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 14:25:25 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-07 21:56:15 -0500
commit21d194d14510abb149d22c8cbd56570cd6b62266 (patch)
tree19a1e91cf186f17f7f678166c28c6e76e0cdb420 /ext/bg/js/audio.js
parenta0d8caffb4f83e0e7219318fa08839ee93e653b8 (diff)
Make _audioInject internal to Backend
Diffstat (limited to 'ext/bg/js/audio.js')
-rw-r--r--ext/bg/js/audio.js44
1 files changed, 0 insertions, 44 deletions
diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js
index c94121ae..361a19cc 100644
--- a/ext/bg/js/audio.js
+++ b/ext/bg/js/audio.js
@@ -138,47 +138,3 @@ function audioUrlNormalize(url, baseUrl, basePath) {
}
return url;
}
-
-function audioBuildFilename(definition) {
- if (definition.reading || definition.expression) {
- let filename = 'yomichan';
- if (definition.reading) {
- filename += `_${definition.reading}`;
- }
- if (definition.expression) {
- filename += `_${definition.expression}`;
- }
-
- return filename += '.mp3';
- }
- return null;
-}
-
-async function audioInject(definition, fields, sources, optionsContext, audioSystem) {
- let usesAudio = false;
- for (const fieldValue of Object.values(fields)) {
- if (fieldValue.includes('{audio}')) {
- usesAudio = true;
- break;
- }
- }
-
- if (!usesAudio) {
- return true;
- }
-
- try {
- const expressions = definition.expressions;
- const audioSourceDefinition = Array.isArray(expressions) ? expressions[0] : definition;
-
- const {uri} = await audioSystem.getDefinitionAudio(audioSourceDefinition, sources, {tts: false, optionsContext});
- const filename = audioBuildFilename(audioSourceDefinition);
- if (filename !== null) {
- definition.audio = {url: uri, filename};
- }
-
- return true;
- } catch (e) {
- return false;
- }
-}