Skip to main content
Version: QTrobot V3

TTS

robot.tts lets QTrobot speak — plain text or SSML, across multiple engines, with full control over voice, language, rate, and pitch. These examples assume you already have a connected robot — see Connection if you haven't set one up yet.

QTrobot ships with Acapela configured as the default TTS engine.

Setup

<script src="https://cdn.jsdelivr.net/npm/@luxai-qtrobot/robot-sdk/dist/qtrobot-sdk.umd.js"></script>
npm install @luxai-qtrobot/robot-sdk

List engines

const engines = await robot.tts.listEngines()
console.log(`Available TTS engines: ${JSON.stringify(engines)}`)

Languages and voices

const langs = await robot.tts.getLanguages({ engine: 'acapela' })
console.log(`acapela languages: ${JSON.stringify(langs)}`)

const voices = await robot.tts.getVoices({ engine: 'acapela' })
console.log(`acapela voices (${voices.length}):`)
for (const v of voices) {
console.log(` ${JSON.stringify(v)}`)
}

Each robot ships with a set of pre-installed Acapela voices, listed above. If you need a voice that isn't installed:

  1. Pick one from the Acapela voice repertoire.
  2. Contact support@luxai.com for instructions on installing it on your robot.

Engine configuration

const cfg = await robot.tts.getConfig({ engine: 'acapela' })
console.log(`acapela config: ${JSON.stringify(cfg)}`)

await robot.tts.setConfig({ config: { pitch: 1.0, rate: 0.8 }, engine: 'acapela' })

Default engine

const engine = await robot.tts.getDefaultEngine()
console.log(`Current default TTS engine: ${engine}`)

await robot.tts.setDefaultEngine({ engine: 'acapela' })

Say text

// Default settings
await robot.tts.sayText({ text: 'Hello, this is spoken with the default settings.' })

// Rate and pitch adjustments
await robot.tts.sayText({ text: 'This is spoken slower at a higher pitch.', engine: 'acapela', rate: 0.85, pitch: 1.2 })

// Explicit voice override
await robot.tts.sayText({ text: 'This is spoken with the Rosie voice.', engine: 'acapela', voice: 'Rosie' })

// Inline Acapela speed tag
await robot.tts.sayText({
text: 'I will speak with different speed. \\rspd=130\\ Now I am speaking faster. \\rspd=70\\ And now I am speaking slower.',
engine: 'acapela',
})

Cancel speech

const controller = new AbortController()
const speech = robot.tts.sayText({
text: 'This is a very long sentence that will be interrupted before it finishes.',
engine: 'acapela',
signal: controller.signal,
})

setTimeout(() => controller.abort(), 2000)

try {
await speech
} catch {
console.log('Speech cancelled.')
}

SSML

Acapela does not support SSML. Instead, it has its own set of special voice tags (like the \rspd=...\ speed tag used above) — see the Acapela voice tag reference for the full list. SSML is supported by other engines, such as Azure below.

const engines = await robot.tts.listEngines() as string[]
for (const engine of engines) {
const supported = await robot.tts.supportsSsml({ engine })
console.log(` ${engine}: SSML supported = ${supported}`)
}
const ssml = `
<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="en-US">
<voice name="en-US-MultiTalker-Ava-Andrew:DragonHDLatestNeural">
<mstts:dialog>
<mstts:turn speaker="ava">Hello Andrew! How is your day going?</mstts:turn>
<mstts:turn speaker="andrew">Hey Ava! It has been great, just exploring QTrobot.</mstts:turn>
</mstts:dialog>
</voice>
</speak>`

await robot.tts.saySsml({ ssml, engine: 'azure' })

Azure TTS

Azure Text-to-Speech is a cloud-based engine offering hundreds of neural voices across 140+ languages, full SSML control (pitch, rate, volume, pauses, pronunciation), and even custom voice cloning. It's a good option when you need a voice, language, or SSML feature Acapela doesn't provide.

1. Get an Azure subscription key

Follow Microsoft's Azure AI Speech documentation to create a free Azure subscription and get your speech resource's subscription key and region.

2. Configure the key on QTRP

From QTPC:

ssh qtrp
sudo nano /opt/luxai/qtrobot_service_hub/etc/tts/azure.yaml

Set your region and subscription key:

parameters:
- name: region
type: string
value: "westeurope" # your Azure resource region

- name: subscription_key
type: string
value: "" # your Azure subscription key

3. Enable the Azure engine

sudo nano /opt/luxai/qtrobot_service_hub/etc/tts/tts.yaml

Add azure to the list of enabled engines:

  - name: engines
type: list[string]
value: [acapela, azure]
scope: cli

4. Restart the service

sudo systemctl restart qtrobot-service-hub.service
sudo systemctl status qtrobot-service-hub.service

Once restarted, azure will show up in robot.tts.listEngines() and is ready to use with sayText({..., engine: 'azure'}) or saySsml({..., engine: 'azure'}).

Next steps

Continue with the Face and Emotion tutorial, or see the full robot.tts namespace in the TypeScript/Node.js API Reference.