Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/add-engines-options' into f…
Browse files Browse the repository at this point in the history
…eat/add-engines-options
  • Loading branch information
Wurielle committed Oct 4, 2024
2 parents e35d646 + 4a9f4fb commit 6a327b5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 50 deletions.
38 changes: 22 additions & 16 deletions apps/app/src/plugins/speech-engines/say/NvSettings.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
<template>
<NvFormItem label="Voice">
<NvVoiceSelect/>
<NvVoiceSelect />
</NvFormItem>
<NvDivider direction="horizontal"/>
<NvDivider direction="horizontal" />
<NvFormItem label="Speed">
<NvGroup>
<NvRangeInput
:max="300"
:min="1"
class="!grow"
v-bind="{
modelValue: getProperty('speed'),
'onUpdate:modelValue': (value) => setProperty('speed', value),
}"
:max="300"
:min="1"
class="!grow"
v-bind="{
modelValue: getProperty('speed'),
'onUpdate:modelValue': (value) => setProperty('speed', value),
}"
/>
<NvNumberInput
:max="300"
:min="1"
v-bind="{
modelValue: getProperty('speed'),
'onUpdate:modelValue': (value) => setProperty('speed', value),
}"
:max="300"
:min="1"
v-bind="{
modelValue: getProperty('speed'),
'onUpdate:modelValue': (value) => setProperty('speed', value),
}"
/>
</NvGroup>
</NvFormItem>
</template>
<script lang="ts" setup>
import { NvDivider, NvFormItem, NvGroup, NvNumberInput, NvRangeInput } from '@packages/ui'
import {
NvDivider,
NvFormItem,
NvGroup,
NvNumberInput,
NvRangeInput,
} from '@packages/ui'
import NvVoiceSelect from './NvVoiceSelect'
import { getProperty, setProperty } from '@/plugins/speech-engines/say/store.ts'
</script>
62 changes: 31 additions & 31 deletions apps/app/src/plugins/speech-engines/say/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ import { getProperty, setProperty } from './store'

const getSelectedVoice = () => getProperty('selectedVoice')
registerEngine({
id: ENGINE_ID,
name: ENGINE_NAME,
category: 'local',
getSelectedVoice,
getVoiceName,
getCredentials() {
return {}
},
getPayload({ text, translatedText, voice }) {
return {
text: translatedText || text,
voice: voice || getSelectedVoice(),
speed: getProperty('speed') / 100,
}
},
getLanguageCode() {
return DEFAULT_LANGUAGE_CODE
},
synthesizeSpeech({ credentials, payload }) {
return api('local').post<Blob>(
'/tts/say/synthesize-speech',
{
credentials,
payload,
},
{ responseType: 'blob' },
)
},
voiceSelectComponent: NvVoiceSelect,
settingsComponent: NvSettings,
store: { setProperty, getProperty },
id: ENGINE_ID,
name: ENGINE_NAME,
category: 'local',
getSelectedVoice,
getVoiceName,
getCredentials() {
return {}
},
getPayload({ text, translatedText, voice }) {
return {
text: translatedText || text,
voice: voice || getSelectedVoice(),
speed: getProperty('speed') / 100,
}
},
getLanguageCode() {
return DEFAULT_LANGUAGE_CODE
},
synthesizeSpeech({ credentials, payload }) {
return api('local').post<Blob>(
'/tts/say/synthesize-speech',
{
credentials,
payload,
},
{ responseType: 'blob' },
)
},
voiceSelectComponent: NvVoiceSelect,
settingsComponent: NvSettings,
store: { setProperty, getProperty },
})
6 changes: 3 additions & 3 deletions apps/app/src/plugins/speech-engines/say/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { definePluginStore } from '@/store'
import { ENGINE_ID } from './shared'

export const { setProperty, getProperty } = definePluginStore(ENGINE_ID, {
selectedVoice: null,
favoriteVoiceIds: [],
speed: 100,
selectedVoice: null,
favoriteVoiceIds: [],
speed: 100,
})

0 comments on commit 6a327b5

Please sign in to comment.