Skip to content

Commit 8a6e56f

Browse files
feat(tts): add voice preview to TTS dialog
Basic implementation of #151
1 parent 1b675b6 commit 8a6e56f

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { TtsConfig, TtsVoice } from 'shared/types/ttsConfig'
2+
3+
export function VoicePreview({ voice }: { voice: TtsVoice }) {
4+
return <audio controls src={voice.preview}></audio>
5+
}

src/renderer/components/TtsVoicesConfig/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useWindowStore } from 'renderer/store'
66
import { TtsConfig, TtsVoice } from 'shared/types/ttsConfig'
77
import { Down, Up } from '../SvgIcons'
88
import { voicesTransliterations } from './voiceTransliterations'
9+
import { VoicePreview } from './VoicePreview'
910

1011
export function TtsVoicesConfigPane({
1112
availableVoices,
@@ -338,6 +339,9 @@ export function TtsVoicesConfigPane({
338339
}
339340
.
340341
</p>
342+
<VoicePreview
343+
voice={availableVoices.find((v) => v.id == voiceId)}
344+
></VoicePreview>
341345
{preferredVoices.find((v) => v.id == voiceId) ? (
342346
<p>
343347
<i>This voice is already in your list.</i>

src/renderer/style/settings.scss

+16-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ $engineColWidth: 8rem;
106106
.tts-voices-config {
107107
display: flex;
108108
flex-direction: column;
109-
gap: .5rem;
109+
gap: .75rem;
110110
height: 100%;
111111

112112
.voice-filters {
@@ -122,11 +122,23 @@ $engineColWidth: 8rem;
122122
}
123123
}
124124
.voice-details {
125-
display: flex;
126-
flex-direction: row;
125+
display: grid;
126+
grid-template-areas: "desc preview"
127+
"add add";
127128
gap: 1rem;
128129
align-items:baseline;
129-
130+
p {
131+
grid-area: desc;
132+
margin-top: .25rem;
133+
margin-bottom: 0;
134+
}
135+
button {
136+
grid-area: add;
137+
}
138+
audio {
139+
grid-area: preview;
140+
height: 1rem;
141+
}
130142
button, label, input {
131143
font-weight: normal;
132144
font-size: 1.1rem;

src/shared/parser/pipelineXmlConverter/voiceToJson.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ function voiceElementToJson(voiceElm: Element): TtsVoice {
66
gender: voiceElm.getAttribute('gender'),
77
lang: voiceElm.getAttribute('lang'),
88
engine: voiceElm.getAttribute('engine'),
9+
href: voiceElm.getAttribute('href'),
10+
preview: voiceElm.getAttribute('preview'),
911
}
1012
voice.id = `${voice.engine}-${voice.name}`
1113
return voice

src/shared/types/ttsConfig.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export type TtsVoice = {
55
gender: string
66
priority?: number
77
id?: string
8+
href: string
9+
preview: string
810
}
911
export type TtsEngineProperty = {
1012
key: string

0 commit comments

Comments
 (0)