Make it talk: say()
background("navy")
circle(width / 2, height / 2, 60, "gold")
say("Hello")
That is a whole program. Run it and the computer says "Hello". There is nothing to import and nothing to set up: no account and no internet, because the voice is the one your device already has.
Change the word and run it again.
say("My name is Sam")
One thing to know from the start: you hear this voice as the scene runs, but it is not recorded into a video file.
How long does it take?
say gives back how many seconds the line takes, so you can wait for it to finish before the next thing happens.
background("navy")
circle(width / 2, height / 2, 60, "gold")
await sleep(say("Hello"))
await sleep(say("This is my first talking program"))
say("Goodbye")
Without a better voice behind it the length is a guess: two and a half words a second, and never less than 0.8 of a second. It is the same guess every time, so a scene that waits for it always works out the same.
A different voice, or another language
say("Half of the width is the middle.", voice="calm")
say("Bonjour tout le monde", lang="fr")
voice is the name of a voice on your device (the names differ from one device to the next, and a name that is not found is simply left out), and lang is the language, "en" unless you say. If the device has a voice for the language, it is used.
What the free voice can and cannot do
It is the voice the browser speaks with, so:
- It is free, works offline, and nothing you type is sent anywhere.
- It sounds a little different on each device, and some devices have few voices.
- You hear it live, but it cannot be recorded. The browser sends it straight to the speaker, so a video made from a scene has the pictures, the music and the sound effects, but not these words.
In a recorded video
Record Video in the footer saves the preview as an MP4 (how). A scene that is recorded has its pictures, its music and its sound effects in the file, in step with each other. The words you make with say are not in it. The voice is spoken by your device straight to its speaker, so it can be heard live but cannot be put into a file, and the video is quiet where the scene spoke.
If a video needs its words, show them as text too: Kinetic text writes them on the picture, and say gives back how long a line takes, so the text can stay on for the same time.