From 8550a2b3b83736596b882aaedda0609992f4c36f Mon Sep 17 00:00:00 2001 From: Natalia Platova Date: Sun, 12 Nov 2023 11:36:13 +0200 Subject: [PATCH 1/4] add card in settings part of #65 --- src/frontend/components/OutputLine.vue | 2 +- .../components/Settings/VoiceSettings.vue | 67 +++++++++++++++++++ src/frontend/store/LINKaStore.ts | 1 + src/frontend/store/index.ts | 5 ++ src/frontend/views/SettingsView.vue | 2 + 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/frontend/components/Settings/VoiceSettings.vue diff --git a/src/frontend/components/OutputLine.vue b/src/frontend/components/OutputLine.vue index 5c5f347..05264b4 100644 --- a/src/frontend/components/OutputLine.vue +++ b/src/frontend/components/OutputLine.vue @@ -146,7 +146,7 @@ function backspace () { async function say () { isPlaying.value = true; if (props.config?.withoutSpace) { - if (text.value) await TTS.instance.playText(text.value); + if (text.value) await TTS.instance.playText(text.value, /*voice*/); } else await TTS.instance.playCards(props.file, props.cards); isPlaying.value = false; } diff --git a/src/frontend/components/Settings/VoiceSettings.vue b/src/frontend/components/Settings/VoiceSettings.vue new file mode 100644 index 0000000..f400353 --- /dev/null +++ b/src/frontend/components/Settings/VoiceSettings.vue @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/src/frontend/store/LINKaStore.ts b/src/frontend/store/LINKaStore.ts index 8e99588..374be69 100644 --- a/src/frontend/store/LINKaStore.ts +++ b/src/frontend/store/LINKaStore.ts @@ -17,6 +17,7 @@ export interface LINKaStore { accent: string, secondary: string } + voice: string, keyMapping: KeyMap selectedKey?: Side; diff --git a/src/frontend/store/index.ts b/src/frontend/store/index.ts index 733bd0f..894d69b 100644 --- a/src/frontend/store/index.ts +++ b/src/frontend/store/index.ts @@ -13,6 +13,7 @@ const fields = [ { commit: "colors_primary", default: "#197377" } as Field, { commit: "colors_accent", default: "#7DF6FA" } as Field, { commit: "colors_secondary", default: "#FFAF00" } as Field, + { commit: "voice", default: "alena"} as Field, { commit: "button_timeout", default: 1000 } as Field, { commit: "button_eyeSelect", default: true } as Field, { commit: "button_eyeActivation", default: true } as Field, @@ -40,6 +41,7 @@ const store = createStore({ accent: "", primary: "#197377" }, + voice: "alena", button: { timeout: 1000, enabled: true, @@ -126,6 +128,9 @@ const store = createStore({ colors_secondary ({ colors }, value) { colors.secondary = value; }, + voice ({ voice }, value) { + voice = value; + }, editor_current ({ editor }, value) { editor.current = value; }, diff --git a/src/frontend/views/SettingsView.vue b/src/frontend/views/SettingsView.vue index 4af9682..90fee16 100644 --- a/src/frontend/views/SettingsView.vue +++ b/src/frontend/views/SettingsView.vue @@ -86,6 +86,7 @@ md="4" > + @@ -104,6 +105,7 @@ import { computed, onMounted } from "vue"; import { useStore } from "vuex"; import ColorSettings from "@/frontend/components/Settings/ColorsSettings.vue"; +import VoiceSettings from "@/frontend/components/Settings/VoiceSettings.vue"; import InputSettings from "@/frontend/components/Settings/InputSettings.vue"; import { Metric } from "@/frontend/utils/Metric"; From e77dd04e1548348d521a0ce27b4927b84d766a7f Mon Sep 17 00:00:00 2001 From: Natalia Platova Date: Sun, 12 Nov 2023 18:32:07 +0200 Subject: [PATCH 2/4] 65 add action for changing voice value --- .../components/EditorView/TTSDialog.vue | 1 + src/frontend/components/OutputLine.vue | 6 +++++- .../components/Settings/VoiceSettings.vue | 20 ++++++++----------- src/frontend/store/index.ts | 4 ++++ src/frontend/views/SettingsView.vue | 7 +++++++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/frontend/components/EditorView/TTSDialog.vue b/src/frontend/components/EditorView/TTSDialog.vue index 4aa8238..943ec63 100644 --- a/src/frontend/components/EditorView/TTSDialog.vue +++ b/src/frontend/components/EditorView/TTSDialog.vue @@ -85,6 +85,7 @@ const voices = [ ]; const dialog = ref(false); const audioText = ref(props.audioText ?? ""); +//const voice = ref(computed(() => store.state.voice)); const voice = ref("alena"); watch(dialog, onDialog); diff --git a/src/frontend/components/OutputLine.vue b/src/frontend/components/OutputLine.vue index 05264b4..db5a58b 100644 --- a/src/frontend/components/OutputLine.vue +++ b/src/frontend/components/OutputLine.vue @@ -102,6 +102,10 @@ const buttonEnabled = computed(() => { return store.state.button.enabled; }); +const voiceToPlay = computed(() => { + return store.state.voice; +}); + const withoutSpace = computed(() => { return props.config?.withoutSpace; }); @@ -146,7 +150,7 @@ function backspace () { async function say () { isPlaying.value = true; if (props.config?.withoutSpace) { - if (text.value) await TTS.instance.playText(text.value, /*voice*/); + if (text.value) await TTS.instance.playText(text.value, voiceToPlay.value); } else await TTS.instance.playCards(props.file, props.cards); isPlaying.value = false; } diff --git a/src/frontend/components/Settings/VoiceSettings.vue b/src/frontend/components/Settings/VoiceSettings.vue index f400353..dee3fb2 100644 --- a/src/frontend/components/Settings/VoiceSettings.vue +++ b/src/frontend/components/Settings/VoiceSettings.vue @@ -5,12 +5,11 @@ v.value === voice.value) || { value: "alena", text: "Алёна" }; - const voiceOption: Ref = ref(defaultVoice.value); - - - function selectColor (e) { - console.log(e.target.value); - } + /*function isDisabled () { + return isPlayingExample; + }*/ function playExample () { + //isPlayingExample = true; const selected = voices.find((v) => v.value === voice.value); - console.log(voices, voice) if (!selected) return; - TTS.instance.playText(selected.text, selected.value); + TTS.instance.playText(selected.text, selected.value) //.finally(()=> isPlayingExample=false); }; \ No newline at end of file diff --git a/src/frontend/store/index.ts b/src/frontend/store/index.ts index 894d69b..12a7450 100644 --- a/src/frontend/store/index.ts +++ b/src/frontend/store/index.ts @@ -233,6 +233,10 @@ const store = createStore({ commit("keyMapping_" + side, state.keyMapping[side].filter((c) => c !== code)); state.selectedKey = undefined; }, + voice_change ({ state }, voice: string) { + state.voice = voice; + //commit("voice"); + }, interface_outputLine ({ state, commit }) { commit("interface_outputLine", !state.ui.outputLine); diff --git a/src/frontend/views/SettingsView.vue b/src/frontend/views/SettingsView.vue index 90fee16..5a7dbf3 100644 --- a/src/frontend/views/SettingsView.vue +++ b/src/frontend/views/SettingsView.vue @@ -86,6 +86,13 @@ md="4" > + + + + From 732ca4c2c377700577f57acb667def99665a3fe1 Mon Sep 17 00:00:00 2001 From: Natalia Platova Date: Sun, 12 Nov 2023 20:08:19 +0200 Subject: [PATCH 3/4] add default voice from settings --- .../components/EditorView/TTSDialog.vue | 15 +-- src/frontend/components/OutputLine.vue | 1 + .../components/Settings/VoiceSettings.vue | 110 ++++++++---------- src/frontend/store/index.ts | 3 +- src/frontend/utils/TTS.ts | 10 ++ 5 files changed, 66 insertions(+), 73 deletions(-) diff --git a/src/frontend/components/EditorView/TTSDialog.vue b/src/frontend/components/EditorView/TTSDialog.vue index 943ec63..393356b 100644 --- a/src/frontend/components/EditorView/TTSDialog.vue +++ b/src/frontend/components/EditorView/TTSDialog.vue @@ -74,19 +74,12 @@ const emit = defineEmits<{(e: "audio", payload: { audioSrcFile: string, audioTex const ui_disabled = computed(() => store.state.ui.disabled); -const voices = [ - { value: "zahar", text: "Захар" }, - { value: "ermil", text: "Емиль" }, - { value: "jane", text: "Джейн" }, - { value: "oksana", text: "Оксана" }, - { value: "alena", text: "Алёна" }, - { value: "filipp", text: "Филипп" }, - { value: "omazh", text: "Ома" } -]; +const voices = TTS.voices; + const dialog = ref(false); const audioText = ref(props.audioText ?? ""); -//const voice = ref(computed(() => store.state.voice)); -const voice = ref("alena"); +const defaultVoice = computed(() => store.state.voice); +const voice = ref(defaultVoice.value); watch(dialog, onDialog); diff --git a/src/frontend/components/OutputLine.vue b/src/frontend/components/OutputLine.vue index db5a58b..02811a5 100644 --- a/src/frontend/components/OutputLine.vue +++ b/src/frontend/components/OutputLine.vue @@ -148,6 +148,7 @@ function backspace () { } async function say () { + if (isPlaying.value) return; isPlaying.value = true; if (props.config?.withoutSpace) { if (text.value) await TTS.instance.playText(text.value, voiceToPlay.value); diff --git a/src/frontend/components/Settings/VoiceSettings.vue b/src/frontend/components/Settings/VoiceSettings.vue index dee3fb2..af173f4 100644 --- a/src/frontend/components/Settings/VoiceSettings.vue +++ b/src/frontend/components/Settings/VoiceSettings.vue @@ -1,63 +1,53 @@ - - \ No newline at end of file +const voice = computed({ + get () { + return store.state.voice; + }, + set (value: string) { + store.dispatch("voice_change", value); + } +}); + +function playExample () { + if (isPlayingExample.value) return; + isPlayingExample.value = true; + const selected = voices.find((v) => v.value === voice.value); + if (!selected) return; + TTS.instance.playText(selected.text, selected.value).finally(() => { + isPlayingExample.value = false; + }); +} + diff --git a/src/frontend/store/index.ts b/src/frontend/store/index.ts index 12a7450..c5a8633 100644 --- a/src/frontend/store/index.ts +++ b/src/frontend/store/index.ts @@ -13,7 +13,7 @@ const fields = [ { commit: "colors_primary", default: "#197377" } as Field, { commit: "colors_accent", default: "#7DF6FA" } as Field, { commit: "colors_secondary", default: "#FFAF00" } as Field, - { commit: "voice", default: "alena"} as Field, + { commit: "voice", default: "alena" } as Field, { commit: "button_timeout", default: 1000 } as Field, { commit: "button_eyeSelect", default: true } as Field, { commit: "button_eyeActivation", default: true } as Field, @@ -235,7 +235,6 @@ const store = createStore({ }, voice_change ({ state }, voice: string) { state.voice = voice; - //commit("voice"); }, interface_outputLine ({ state, commit }) { diff --git a/src/frontend/utils/TTS.ts b/src/frontend/utils/TTS.ts index f10ab45..92d92eb 100644 --- a/src/frontend/utils/TTS.ts +++ b/src/frontend/utils/TTS.ts @@ -13,6 +13,16 @@ export class TTS { return TTS._instance; } + static voices = [ + { value: "zahar", text: "Захар" }, + { value: "ermil", text: "Емиль" }, + { value: "jane", text: "Джейн" }, + { value: "oksana", text: "Оксана" }, + { value: "alena", text: "Алёна" }, + { value: "filipp", text: "Филипп" }, + { value: "omazh", text: "Ома" } + ]; + public async playCards (file: string, cards: Card[], force = false) { if (this.isPlaying) { this.isPlaying = false; From e7361adcdf39965406c8b2244f8fd06ebeadf529 Mon Sep 17 00:00:00 2001 From: Natalia Platova Date: Mon, 20 Nov 2023 21:09:16 +0200 Subject: [PATCH 4/4] add saving voice to config --- src/common/interfaces/ConfigFile.ts | 1 + .../components/EditorView/TTSDialog.vue | 46 +++++++++++++------ src/frontend/views/EditorView.vue | 10 +++- 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/common/interfaces/ConfigFile.ts b/src/common/interfaces/ConfigFile.ts index a5b8ba7..46a71bb 100644 --- a/src/common/interfaces/ConfigFile.ts +++ b/src/common/interfaces/ConfigFile.ts @@ -11,6 +11,7 @@ export interface Card { title?: string; audioPath?: string; audioText?: string; + audioVoice?: string answer?: true } diff --git a/src/frontend/components/EditorView/TTSDialog.vue b/src/frontend/components/EditorView/TTSDialog.vue index 393356b..ef30847 100644 --- a/src/frontend/components/EditorView/TTSDialog.vue +++ b/src/frontend/components/EditorView/TTSDialog.vue @@ -21,8 +21,8 @@