Let's build a simple text-to-speech app using the Sonna API in JavaScript.
Install the SDK
npm install @sonna/sonna-jsInitialize the client
import { SonnaClient } from '@sonna/sonna-js'
const client = new SonnaClient({
apiKey: process.env.SONNA_API_KEY
})Generate audio
const audio = await client.textToSpeech.convert({
text: "Hello from Sonna!",
voiceId: "your_voice_id"
})That's it. The response is a binary audio buffer you can play, save, or stream.