fix(stage-web|stage-tamagotchi|stage-ui): types

This commit is contained in:
Neko Ayaka
2025-03-15 22:15:34 +08:00
parent b8d93b6d7d
commit 2859356690
5 changed files with 18 additions and 30 deletions
@@ -14,7 +14,7 @@ const {
const { const {
activeSpeechProvider, activeSpeechProvider,
activeSpeechModel, activeSpeechModel,
voiceName, voiceId,
pitch, pitch,
rate, rate,
isLoadingSpeechProviderVoices, isLoadingSpeechProviderVoices,
@@ -26,7 +26,7 @@ const {
const router = useRouter() const router = useRouter()
const ssmlExample = ref(`<speak> const ssmlExample = ref(`<speak>
Hello, my name is <voice name="${voiceName.value || 'Default'}"> Hello, my name is <voice name="${voiceId.value || 'Default'}">
<prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}"> <prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}">
AI Assistant AI Assistant
</prosody> </prosody>
@@ -40,18 +40,18 @@ onMounted(async () => {
}) })
function updateVoiceName(value: string) { function updateVoiceName(value: string) {
voiceName.value = value voiceId.value = value
updateSSMLExample() updateSSMLExample()
} }
function updateCustomVoiceName(value: string) { function updateCustomVoiceName(value: string) {
voiceName.value = value voiceId.value = value
updateSSMLExample() updateSSMLExample()
} }
function updateSSMLExample() { function updateSSMLExample() {
ssmlExample.value = `<speak> ssmlExample.value = `<speak>
Hello, my name is <voice name="${voiceName.value || 'Default'}"> Hello, my name is <voice name="${voiceId.value || 'Default'}">
<prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}"> <prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}">
AI Assistant AI Assistant
</prosody> </prosody>
@@ -159,7 +159,7 @@ function updateSSMLExample() {
<!-- Voice selection with RadioCardDetailManySelect --> <!-- Voice selection with RadioCardDetailManySelect -->
<div v-else-if="availableVoices[activeSpeechProvider] && availableVoices[activeSpeechProvider].length > 0" class="space-y-6"> <div v-else-if="availableVoices[activeSpeechProvider] && availableVoices[activeSpeechProvider].length > 0" class="space-y-6">
<RadioCardDetailManySelect <RadioCardDetailManySelect
v-model="voiceName" v-model="voiceId"
v-model:search-query="voiceSearchQuery" v-model:search-query="voiceSearchQuery"
:items="availableVoices[activeSpeechProvider]?.map(voice => ({ :items="availableVoices[activeSpeechProvider]?.map(voice => ({
id: voice.name, id: voice.name,
@@ -284,7 +284,8 @@ function updateSSMLExample() {
Voice Name Voice Name
</label> </label>
<input <input
v-model="voiceName" type="text" v-model="voiceId"
type="text"
class="w-full border border-neutral-300 rounded bg-white px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900" class="w-full border border-neutral-300 rounded bg-white px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900"
placeholder="Enter voice name (e.g., 'Rachel', 'Josh')" placeholder="Enter voice name (e.g., 'Rachel', 'Josh')"
@input="(event) => updateVoiceName((event.target as HTMLInputElement).value)" @input="(event) => updateVoiceName((event.target as HTMLInputElement).value)"
@@ -156,14 +156,6 @@ watch([apiKey, baseUrl, similarityBoost, stability, speed, style, useSpeakerBoos
} }
}) })
watch(selectedLanguage, (newLanguage) => {
speechStore.setLanguage(newLanguage)
})
watch(selectedVoice, (newVoice) => {
speechStore.setVoiceName(newVoice)
})
// Function to generate speech // Function to generate speech
async function generateTestSpeech() { async function generateTestSpeech() {
if (!testText.value.trim()) if (!testText.value.trim())
@@ -14,7 +14,7 @@ const {
const { const {
activeSpeechProvider, activeSpeechProvider,
activeSpeechModel, activeSpeechModel,
voiceName, voiceId,
pitch, pitch,
rate, rate,
isLoadingSpeechProviderVoices, isLoadingSpeechProviderVoices,
@@ -26,7 +26,7 @@ const {
const router = useRouter() const router = useRouter()
const ssmlExample = ref(`<speak> const ssmlExample = ref(`<speak>
Hello, my name is <voice name="${voiceName.value || 'Default'}"> Hello, my name is <voice name="${voiceId.value || 'Default'}">
<prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}"> <prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}">
AI Assistant AI Assistant
</prosody> </prosody>
@@ -40,18 +40,18 @@ onMounted(async () => {
}) })
function updateVoiceName(value: string) { function updateVoiceName(value: string) {
voiceName.value = value voiceId.value = value
updateSSMLExample() updateSSMLExample()
} }
function updateCustomVoiceName(value: string) { function updateCustomVoiceName(value: string) {
voiceName.value = value voiceId.value = value
updateSSMLExample() updateSSMLExample()
} }
function updateSSMLExample() { function updateSSMLExample() {
ssmlExample.value = `<speak> ssmlExample.value = `<speak>
Hello, my name is <voice name="${voiceName.value || 'Default'}"> Hello, my name is <voice name="${voiceId.value || 'Default'}">
<prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}"> <prosody pitch="+${pitch.value || 0}%" rate="${rate.value || 1}">
AI Assistant AI Assistant
</prosody> </prosody>
@@ -159,7 +159,7 @@ function updateSSMLExample() {
<!-- Voice selection with RadioCardDetailManySelect --> <!-- Voice selection with RadioCardDetailManySelect -->
<div v-else-if="availableVoices[activeSpeechProvider] && availableVoices[activeSpeechProvider].length > 0" class="space-y-6"> <div v-else-if="availableVoices[activeSpeechProvider] && availableVoices[activeSpeechProvider].length > 0" class="space-y-6">
<RadioCardDetailManySelect <RadioCardDetailManySelect
v-model="voiceName" v-model="voiceId"
v-model:search-query="voiceSearchQuery" v-model:search-query="voiceSearchQuery"
:items="availableVoices[activeSpeechProvider]?.map(voice => ({ :items="availableVoices[activeSpeechProvider]?.map(voice => ({
id: voice.name, id: voice.name,
@@ -284,7 +284,8 @@ function updateSSMLExample() {
Voice Name Voice Name
</label> </label>
<input <input
v-model="voiceName" type="text" v-model="voiceId"
type="text"
class="w-full border border-neutral-300 rounded bg-white px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900" class="w-full border border-neutral-300 rounded bg-white px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900"
placeholder="Enter voice name (e.g., 'Rachel', 'Josh')" placeholder="Enter voice name (e.g., 'Rachel', 'Josh')"
@input="(event) => updateVoiceName((event.target as HTMLInputElement).value)" @input="(event) => updateVoiceName((event.target as HTMLInputElement).value)"
@@ -156,14 +156,6 @@ watch([apiKey, baseUrl, similarityBoost, stability, speed, style, useSpeakerBoos
} }
}) })
watch(selectedLanguage, (newLanguage) => {
speechStore.setLanguage(newLanguage)
})
watch(selectedVoice, (newVoice) => {
speechStore.setVoiceName(newVoice)
})
// Function to generate speech // Function to generate speech
async function generateTestSpeech() { async function generateTestSpeech() {
if (!testText.value.trim()) if (!testText.value.trim())
@@ -14,6 +14,7 @@ export const useSpeechStore = defineStore('speech', () => {
const activeSpeechProvider = useLocalStorage('settings/speech/active-provider', '') const activeSpeechProvider = useLocalStorage('settings/speech/active-provider', '')
const activeSpeechModel = useLocalStorage('settings/speech/active-model', 'eleven_multilingual_v2') const activeSpeechModel = useLocalStorage('settings/speech/active-model', 'eleven_multilingual_v2')
const voiceName = useLocalStorage('settings/speech/voice-name', '') const voiceName = useLocalStorage('settings/speech/voice-name', '')
const voiceId = useLocalStorage('settings/speech/voice-id', '')
const pitch = useLocalStorage('settings/speech/pitch', 0) const pitch = useLocalStorage('settings/speech/pitch', 0)
const rate = useLocalStorage('settings/speech/rate', 1) const rate = useLocalStorage('settings/speech/rate', 1)
const ssmlEnabled = useLocalStorage('settings/speech/ssml-enabled', false) const ssmlEnabled = useLocalStorage('settings/speech/ssml-enabled', false)
@@ -137,6 +138,7 @@ export const useSpeechStore = defineStore('speech', () => {
activeSpeechProvider, activeSpeechProvider,
activeSpeechModel, activeSpeechModel,
voiceName, voiceName,
voiceId,
pitch, pitch,
rate, rate,
ssmlEnabled, ssmlEnabled,