feat(showcase): add remaining operator voices

This commit is contained in:
Haoyu Xu
2023-02-10 23:34:23 -05:00
parent 808d0ff6da
commit c7585f93a6
5 changed files with 151 additions and 17 deletions

View File

@@ -23,6 +23,8 @@ localization:
ui_position_padding_top: Padding Top
ui_voice_title: <hr><h4>🔈Voice</h4><hr>
ui_voice_lang: Voice Language
ui_voice_idle: Idle Timeout
ui_voice_next: Voice Interval
ui_subtitle_title: <hr><h4>📑 Subtitle</h4><hr>
ui_subtitle_lang: Subtitle Language
ui_voice_actor_title: <hr><h4>🗣️ Voice Actor</h4><hr>
@@ -49,6 +51,8 @@ localization:
ui_position_padding_top: 上部距离
ui_voice_title: <hr><h4>🔈语音</h4><hr>
ui_voice_lang: 语音语言
ui_voice_idle: 待机间隔
ui_voice_next: 下一条语音间隔
ui_subtitle_title: <hr><h4>📑 字幕</h4><hr>
ui_subtitle_lang: 字幕语言
ui_voice_actor_title: <hr><h4>🗣️ 声优</h4><hr>
@@ -128,15 +132,77 @@ properties:
text: ui_default_background
type: combo
value: !match ~{var('assets', "backgrounds")[0]}
fraction: false
max: 100
min: 0
options: !match ~{var('assets', "backgroundOptions")}
options: !match ~{var('assets', "backgroundsOptions")}
- key: background
value:
text: ui_custom_background
type: file
value: ""
- key: voicetitle
value:
text: ui_voice_title
type: bool
value: false
- key: voicelanguage
value:
text: ui_voice_lang
type: combo
condition: voicetitle.value == true
value: !match ~{var('assets', "voiceLangs")[0]}
options: !match ~{var('assets', "voiceLangsOptions")}
- key: voiceidle
value:
text: ui_voice_idle
type: textinput
value: 10
condition: voicetitle.value == true
fraction: false
min: 0
- key: voicenext
value:
text: ui_voice_next
type: textinput
value: 3
condition: voicetitle.value == true
fraction: false
min: 0
- key: voicesubtitle
value:
text: ui_subtitle_title
condition: voicetitle.value == true
type: bool
value: false
- key: voicesubtitlelanguage
value:
text: ui_subtitle_lang
type: combo
condition: voicesubtitle.value == true
value: !match ~{var('assets', "subtitleLangs")[0]}
options: !match ~{var('assets', "subtitleLangsOptions")}
- key: voicesubtitlex
value:
text: ui_translate_x
type: slider
value: 0
condition: voicesubtitle.value == true
fraction: false
max: 100
min: 0
- key: voicesubtitley
value:
text: ui_translate_y
type: slider
value: 100
condition: voicesubtitle.value == true
fraction: false
max: 100
min: 0
- key: voiceactor
value:
text: ui_voice_actor_title
condition: voicesubtitle.value == true
type: bool
value: false
- key: position
value:
text: ui_position_title

View File

@@ -23,12 +23,18 @@ export default class ProjectJson {
this.#json = JSON.parse(await readFile(this.#getPath()))
const matcher = new Matcher('~{', '}', __config.operators[this.#operatorName], {
...this.#assets,
backgroundOptions: this.#assets.backgrounds.map((b) => {
return {
"label": b,
"value": b
...(() => {
const output = {}
for (const [key, value] of Object.entries(this.#assets)) {
output[`${key}Options`] = value.map((b) => {
return {
"label": b,
"value": b
}
})
}
})
return output
})()
})
const match = {
identify: value => value.startsWith('!match'),

View File

@@ -75,8 +75,35 @@ async function main() {
rmdir(OPERATOR_RELEASE_FOLDER)
const charwordTableLookup = charwordTable.lookup(OPERATOR_NAME)
const voiceLangs = (() => {
const infoArray = Object.values(charwordTableLookup.operator.info[charwordTableLookup.config.default_region])
// combine the infoArray
let output = {}
for (const info of infoArray) {
output = {
...output,
...info
}
}
return Object.keys(output)
})()
const subtitleLangs = (() => {
const output = []
for (const [key, value] of Object.entries(charwordTableLookup.operator.info)) {
if (Object.keys(value).length !== 0) {
output.push(key)
}
}
return output
})()
writeSync(JSON.stringify(charwordTableLookup), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'charword_table.json'))
const projectJson = new ProjectJson(OPERATOR_NAME, OPERATOR_SHARE_FOLDER, {
backgrounds
backgrounds,
voiceLangs,
subtitleLangs
})
projectJson.load().then((content) => {
write(JSON.stringify(content, null, 2), path.join(OPERATOR_RELEASE_FOLDER, 'project.json'))
@@ -87,8 +114,6 @@ async function main() {
write(JSON.stringify(content.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets.json`))
})
writeSync(JSON.stringify(charwordTable.lookup(OPERATOR_NAME)), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'charword_table.json'))
const filesToCopy = [
...background.getFilesToCopy(SHOWCASE_PUBLIC_ASSSETS_FOLDER),
{

View File

@@ -61,6 +61,7 @@ export default class Voice {
set useSubtitle(show) {
this.#useSubtitle = show
this.#el.hidden = !show
window.settings.functionInsights("useSubtitle")
}
get useSubtitle() {
@@ -71,6 +72,7 @@ export default class Voice {
* @param {boolean} show
*/
set useVoice(show) {
window.settings.functionInsights("useVoice")
this.#useVoice = show
this.#el.hidden = !show
this.#playEntryVoice()
@@ -89,6 +91,7 @@ export default class Voice {
set useVoiceActor(show) {
this.#useVoiceActor = show
document.getElementById('voice_actor_box').hidden = !show
window.settings.functionInsights("useVoiceActor")
}
get useVoiceActor() {
@@ -104,6 +107,7 @@ export default class Voice {
} else {
this.#subtitleLang = this.#defaultRegion
}
window.settings.functionInsights("subtitleLanguage")
}
get subtitleLanguage() {
@@ -140,6 +144,7 @@ export default class Voice {
#updateSubtitlePosition() {
window.settings.elementPosition(this.#el, this.#subtitleX, this.#subtitleY)
window.settings.functionInsights("subtitlePosition")
}
/**
@@ -151,6 +156,7 @@ export default class Voice {
} else {
this.#voiceLang = this.#defaultVoiceLang
}
window.settings.functionInsights("language")
const availableSubtitleLang = this.#getSubtitleLanguages()
if (!availableSubtitleLang.includes(this.#subtitleLang)) {
this.#subtitleLang = availableSubtitleLang[0]
@@ -174,6 +180,7 @@ export default class Voice {
this.#idleDuration = duration * 60 * 1000
this.#initIdleVoiceTimer()
}
window.settings.functionInsights("idleDuration")
}
get idleDuration() {
@@ -189,6 +196,7 @@ export default class Voice {
this.#nextDuration = duration * 60 * 1000
this.#initNextVoiceTimer()
}
window.settings.functionInsights("nextDuration")
}
get nextDuration() {
@@ -227,7 +235,7 @@ export default class Voice {
if (id === null) {
setTimeout(() => {
if (this.#isPlaying) return
this.#el.style.opacity = 1
this.#el.style.opacity = 0
}, 5 * 1000);
return
}
@@ -246,7 +254,7 @@ export default class Voice {
this.#lastVoiceId = this.#currentVoiceId
this.#currentVoiceId = id
this.#audioEl.src = `./assets/${this.#getVoiceFoler()
}/${id}.wav`
}/${id}.ogg`
let startPlayPromise = this.#audioEl.play()
if (startPlayPromise !== undefined) {
startPlayPromise
@@ -365,9 +373,11 @@ export default class Voice {
<div class="voice-triangle"></div>
</div>
</div>
<div class="voice-actor" id="voice_actor_box" hidden>
<span class="voice-actor-icon"></span>
<span id="voice_actor_name" class="voice-actor-name"></span>
<div id="voice_actor_box" hidden>
<div class="voice-actor">
<span class="voice-actor-icon"></span>
<span id="voice_actor_name" class="voice-actor-name"></span>
</div>
</div>
`
}

View File

@@ -44,6 +44,33 @@ window.wallpaperPropertyListener = {
window.settings.resetBackground()
}
}
if (properties.voicetitle) {
window.voice.useVoice = properties.voicetitle.value
}
if (properties.voicelanguage) {
window.voice.language = properties.voicelanguage.value
}
if (properties.voiceidle) {
window.voice.idleDuration = parseInt(properties.voiceidle.value)
}
if (properties.voicenext) {
window.voice.nextDuration = parseInt(properties.voicenext.value)
}
if (properties.voicesubtitle) {
window.voice.useSubtitle = properties.voicesubtitle.value
}
if (properties.voicesubtitlelanguage) {
window.voice.subtitleLanguage = properties.voicesubtitlelanguage.value
}
if (properties.voicesubtitlex) {
window.voice.subtitleX = properties.voicesubtitlex.value
}
if (properties.voicesubtitley) {
window.voice.subtitleY = properties.voicesubtitley.value
}
if (properties.voiceactor) {
window.voice.useVoiceActor = properties.voiceactor.value
}
if (properties.position) {
if (!properties.position.value) {
window.settings.positionReset()