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:
key | Type | Default | Description |
---|---|---|---|
voice | string | alloy | Defines the voice to use for reading aloud |
model | string | tts-1 | The 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.