Commit d22c5c4d authored by Dazzle Wu's avatar Dazzle Wu

fix: 视频数字人音频语言

parent af13dd9c
import { AudioConfig, LangType, VoiceType } from '@/store/types/creation'
import { AudioConfig, VoiceType } from '@/store/types/creation'
import { defineStore } from 'pinia'
function defaultAudioSetting(): AudioConfig {
return {
langType: LangType.CANTONESE,
voiceType: VoiceType.CANTONESE_FEMALE,
consumption: 0,
}
......@@ -17,10 +16,6 @@ export const useAudioSettingStore = defineStore('audio-setting-store', {
state: (): AudioConfig => getLocalState(),
actions: {
setLanType(langType: LangType) {
this.langType = langType
},
setVoiceType(voiceType: VoiceType) {
this.voiceType = voiceType
},
......
......@@ -114,6 +114,10 @@ export const useDigitalCreationStore = defineStore('digital-creation-store', {
this.enabled = subtitleEnabled
},
setPronunciationLanguage(pronunciationLanguage: LangType) {
this.pronunciationLanguage = pronunciationLanguage
},
updateDigitalCreation(digitalCreation: Partial<DraftConfig>) {
this.$state = { ...this.$state, ...digitalCreation }
},
......
......@@ -28,7 +28,6 @@ export enum VoiceType {
}
export interface AudioConfig {
langType: LangType
voiceType: VoiceType
consumption: number
}
......
......@@ -42,10 +42,10 @@ const showAll = ref(false)
const langType = computed({
get() {
return audioSettingStore.langType
return digitalCreationStore.pronunciationLanguage
},
set(value) {
audioSettingStore.setLanType(value)
digitalCreationStore.setPronunciationLanguage(value)
},
})
......@@ -94,6 +94,7 @@ watch(
watch(
() => langType.value,
(newVal) => {
digitalCreationStore.setInputAudioUrl('')
if (newVal === LangType.CANTONESE) {
digitalCreationStore.setPerson('')
audioSettingStore.setVoiceType(VoiceType.CANTONESE_FEMALE)
......
......@@ -123,7 +123,7 @@ function controlAudio() {
audioSetting.value.voiceType !== audioSettingStore.voiceType ||
audioSetting.value.speed !== ttsSpeedMarks[digitalCreationStore.speed] ||
audioSetting.value.volume !== Number(digitalCreationStore.volume) ||
(audioSettingStore.langType === LangType.MANDARIN &&
(digitalCreationStore.pronunciationLanguage === LangType.MANDARIN &&
audioSetting.value.pitch !== Number(digitalCreationStore.pitch))
) {
audioData.value = ''
......
......@@ -76,10 +76,9 @@ async function getDigitalTemplate(id: string) {
logoUrl: digitalTemplate.logoParams?.logoUrl || null,
bgmUrl: digitalTemplate.bgmParams?.bgmUrl || null,
materialUrl: digitalTemplate.materialUrl,
pronunciationLanguage: digitalCreationStore.pronunciationLanguage,
pronunciationLanguage: digitalTemplate.ttsParams?.person ? LangType.MANDARIN : LangType.CANTONESE,
}
digitalCreationStore.updateDigitalCreation(draftConfig)
audioSettingStore.setLanType(draftConfig.person ? LangType.MANDARIN : LangType.CANTONESE)
audioSettingStore.setVoiceType(draftConfig.person ? VoiceType.MANDARIN_FEMALE : VoiceType.CANTONESE_FEMALE)
}
}
......@@ -88,7 +87,6 @@ async function getDraft(id: string) {
const res = await fetchDraftConfigById<DraftConfig>(id)
if (res.code === 0) {
digitalCreationStore.updateDigitalCreation(res.data)
audioSettingStore.setLanType(res.data.person ? LangType.MANDARIN : LangType.CANTONESE)
audioSettingStore.setVoiceType(res.data.person ? VoiceType.MANDARIN_FEMALE : VoiceType.CANTONESE_FEMALE)
}
}
......@@ -127,10 +125,9 @@ async function getTaskConfig(id: string) {
logoUrl: res.data.logoUrl || digitalCreationStore.logoUrl,
bgmUrl: res.data.bgmUrl || digitalCreationStore.bgmUrl,
materialUrl: res.data.materialUrl || digitalCreationStore.materialUrl,
pronunciationLanguage: res.data.pronunciationLanguage || digitalCreationStore.pronunciationLanguage,
pronunciationLanguage: res.data.person ? LangType.MANDARIN : LangType.CANTONESE,
}
digitalCreationStore.updateDigitalCreation(draftConfig)
audioSettingStore.setLanType(draftConfig.person ? LangType.MANDARIN : LangType.CANTONESE)
audioSettingStore.setVoiceType(draftConfig.person ? VoiceType.MANDARIN_FEMALE : VoiceType.CANTONESE_FEMALE)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment