Text to Speech

Allows you to read a message aloud with one of chatGPT's voices

const audioURLBase64 = await useGPT('Read this aloud').toSpeech()

.toSpeech(options)

takes optional options with the following properties:

keyTypeDefaultDescription
voicestringalloyDefines the voice to use for reading aloud
modelstringtts-1The model to use for text-to-speech

Example (playing audio):

<script setup lang="ts">
    const audioURLBase64 = await useGPT('Read this aloud').toSpeech()
    const audio = new Audio(audioURLBase64)
</script>

<template>
    <button @click="audio.play()">
        Read aloud
    </button>
</template>
Note: Most Browsers require user action to play audio. Thats why there is a button in the above example.