summaryrefslogtreecommitdiff
path: root/ext/bg/js/audio.js
diff options
context:
space:
mode:
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;
- }
-}