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