verbs
This commit is contained in:
1 parent
cb180a6e61
commit
be03bb295b
2 files changed
+207
-12
No files matched your search
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, useTemplateRef } from "vue";
|
||||
import { useTemplateRef } from "vue";
|
||||
import { speak, getVoices } from "tauri-plugin-tts-api";
|
||||
|
||||
const { lang = "ko" } = defineProps<{
|
||||
@@ -18,20 +18,15 @@ const { lang = "ko" } = defineProps<{
|
||||
lang?: string;
|
||||
}>();
|
||||
|
||||
const voiceIds = ref<string[]>([]);
|
||||
|
||||
const mainEl = useTemplateRef("main");
|
||||
|
||||
async function playAudio() {
|
||||
if (!mainEl.value) return;
|
||||
|
||||
if (!voiceIds.value.length) {
|
||||
voiceIds.value = (await getVoices(lang)).map((v) => v.id);
|
||||
if (!voiceIds.value.length) return;
|
||||
}
|
||||
const voices = await getVoices(lang);
|
||||
if (!voices.length) return;
|
||||
|
||||
const voiceId =
|
||||
voiceIds.value[Math.floor(Math.random() * voiceIds.value.length)];
|
||||
const v = voices[Math.floor(Math.random() * voices.length)];
|
||||
await speak({
|
||||
text: mainEl.value.innerText,
|
||||
language: null,
|
||||
@@ -39,7 +34,7 @@ async function playAudio() {
|
||||
volume: null,
|
||||
pitch: null,
|
||||
queueMode: null,
|
||||
voiceId,
|
||||
voiceId: v.id,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user