The Voice elements allow you to easily add voice-over to your videos by simply indicating the text to be spoken and the type of voice (and language) to be used.
{
"resolution": "full-hd",
"quality": "high",
"scenes": [
{
"comment": "Scene #1",
"elements": [
{
"type": "image",
"src": "https://assets.json2video.com/assets/images/space-apollo11-01.jpg",
"scale": {
"width": 1920,
"height": 1280
},
"zoom": 5
},
{
"type": "voice",
"text": "That's one small step for a man, one giant leap for mankind. Upon taking a \"small step\" onto the surface of the moon in 1969, Neil Armstrong uttered what would become one of history's most famous one-liners.",
"start": 1.5
}
]
}
]
}
require 'vendor/autoload.php';
use JSON2Video\Movie;
use JSON2Video\Scene;
// Create and initialize the movie object
$movie = new Movie;
$movie->setAPIKey(YOUR_API_KEY);
$movie->resolution = 'full-hd';
$movie->quality = 'high';
// Create the scenes of the movie
// Create SCENE 1
$scene1 = new Scene;
$scene1->comment = 'Scene #1';
$scene1->addElement([
'type' => 'image',
'src' => 'https://assets.json2video.com/assets/images/space-apollo11-01.jpg',
'scale' => [
'width' => 1920,
'height' => 1280
],
'zoom' => 5
]);
$scene1->addElement([
'type' => 'voice',
'text' => 'That\'s one small step for a man, one giant leap for mankind. Upon taking a "small step" onto the surface of the moon in 1969, Neil Armstrong uttered what would become one of history\'s most famous one-liners.',
'start' => 1.5
]);
$movie->addScene($scene1);
// Finally, render the movie
$movie->render();
// Wait for the movie to be rendered
$movie->waitToFinish();
let movie = new Movie;
movie.setAPIKey(YOUR_API_KEY);
movie.set("resolution", "full-hd");
movie.set("quality", "high");
// Create the scenes of the movie
// Create SCENE 1
let scene1 = new Scene;
scene1.set("comment", "Scene #1");
scene1.addElement({
"type": "image",
"src": "https://assets.json2video.com/assets/images/space-apollo11-01.jpg",
"scale": {
"width": 1920,
"height": 1280
},
"zoom": 5
});
scene1.addElement({
"type": "voice",
"text": "That's one small step for a man, one giant leap for mankind. Upon taking a \"small step\" onto the surface of the moon in 1969, Neil Armstrong uttered what would become one of history's most famous one-liners.",
"start": 1.5
});
movie.addScene(scene1);
// Finally, render the movie
movie.render();
// Wait for the movie to be rendered
movie.waitToFinish();
The resulting video is:
The video uses one scene with 2 elements:
The first element is an image re-scaled down to 1920x1280 to keep the original 3:2 aspect ratio
The second element is a voice element with the voice-over text that starts 1.5 seconds from the beginning of the scene
In this example, we are not indicating the voice to use, so it uses the default value for the voice field: en-GB-LibbyNeural.
Using multiple voices
In this example, we will use two voices in two different languages to showcase the Voice element features.
{
"resolution": "full-hd",
"quality": "high",
"scenes": [
{
"comment": "Scene #1",
"elements": [
{
"type": "image",
"src": "https://assets.json2video.com/assets/images/woman-01.jpg",
"y": -100
},
{
"type": "voice",
"text": "Hello Diego! Could you please introduce yourself in Italian?",
"voice": "en-US-AriaNeural",
"start": 1
}
]
},
{
"comment": "Scene #2",
"elements": [
{
"type": "image",
"src": "https://assets.json2video.com/assets/images/man-01.jpg",
"y": -100
},
{
"type": "voice",
"text": "S\u00ec, certo, Aria. Mi chiamo Diego Rossi e sono di Firenze.",
"voice": "it-IT-DiegoNeural"
}
]
}
]
}
require 'vendor/autoload.php';
use JSON2Video\Movie;
use JSON2Video\Scene;
// Create and initialize the movie object
$movie = new Movie;
$movie->setAPIKey(YOUR_API_KEY);
$movie->resolution = 'full-hd';
$movie->quality = 'high';
// Create the scenes of the movie
// Create SCENE 1
$scene1 = new Scene;
$scene1->comment = 'Scene #1';
$scene1->addElement([
'type' => 'image',
'src' => 'https://assets.json2video.com/assets/images/woman-01.jpg',
'y' => -100
]);
$scene1->addElement([
'type' => 'voice',
'text' => 'Hello Diego! Could you please introduce yourself in Italian?',
'voice' => 'en-US-AriaNeural',
'start' => 1
]);
$movie->addScene($scene1);
// Create SCENE 2
$scene2 = new Scene;
$scene2->comment = 'Scene #2';
$scene2->addElement([
'type' => 'image',
'src' => 'https://assets.json2video.com/assets/images/man-01.jpg',
'y' => -100
]);
$scene2->addElement([
'type' => 'voice',
'text' => 'Sì, certo, Aria. Mi chiamo Diego Rossi e sono di Firenze.',
'voice' => 'it-IT-DiegoNeural'
]);
$movie->addScene($scene2);
// Finally, render the movie
$movie->render();
// Wait for the movie to be rendered
$movie->waitToFinish();
let movie = new Movie;
movie.setAPIKey(YOUR_API_KEY);
movie.set("resolution", "full-hd");
movie.set("quality", "high");
// Create the scenes of the movie
// Create SCENE 1
let scene1 = new Scene;
scene1.set("comment", "Scene #1");
scene1.addElement({
"type": "image",
"src": "https://assets.json2video.com/assets/images/woman-01.jpg",
"y": -100
});
scene1.addElement({
"type": "voice",
"text": "Hello Diego! Could you please introduce yourself in Italian?",
"voice": "en-US-AriaNeural",
"start": 1
});
movie.addScene(scene1);
// Create SCENE 2
let scene2 = new Scene;
scene2.set("comment", "Scene #2");
scene2.addElement({
"type": "image",
"src": "https://assets.json2video.com/assets/images/man-01.jpg",
"y": -100
});
scene2.addElement({
"type": "voice",
"text": "Sì, certo, Aria. Mi chiamo Diego Rossi e sono di Firenze.",
"voice": "it-IT-DiegoNeural"
});
movie.addScene(scene2);
// Finally, render the movie
movie.render();
// Wait for the movie to be rendered
movie.waitToFinish();
The resulting video is:
The video simulates a short conversation between an English-speaking woman and an Italian-speaking man.
In the first scene, we add an image of the woman, a text element with the subtitle and a Voice element with the English text
In the second scene, we add an image of the man, the subtitle and the Voice element with the Italian text
Changing the pace of the voice
You can use a few tags to change the pace of the voice:
<super-slow>: makes the voice very slow
<slow>: makes the voice a bit slower
<normal>: makes the voice normal speed
<fast>: makes the voice a bit faster
<super-fast>: makes the voice very fast
Just wrap the text with the tags to apply the voice change. Examples:
{
"resolution": "full-hd",
"quality": "high",
"scenes": [
{
"comment": "Scene #1",
"elements": [
{
"type": "voice",
"text": "That's one small step for a man, <super-slow>one giant leap for mankind</super-slow>. <fast>Upon taking a \"small step\" onto the surface of the moon in 1969</fast>, Neil Armstrong uttered what would become <slow>one of history's most famous one-liners</slow>.",
"start": 1.5
}
]
}
]
}
require 'vendor/autoload.php';
use JSON2Video\Movie;
use JSON2Video\Scene;
// Create and initialize the movie object
$movie = new Movie;
$movie->setAPIKey(YOUR_API_KEY);
$movie->resolution = 'full-hd';
$movie->quality = 'high';
// Create the scenes of the movie
// Create SCENE 1
$scene1 = new Scene;
$scene1->comment = 'Scene #1';
$scene1->addElement([
'type' => 'voice',
'text' => 'That\'s one small step for a man, <super-slow>one giant leap for mankind</super-slow>. <fast>Upon taking a "small step" onto the surface of the moon in 1969</fast>, Neil Armstrong uttered what would become <slow>one of history\'s most famous one-liners</slow>.',
'start' => 1.5
]);
$movie->addScene($scene1);
// Finally, render the movie
$movie->render();
// Wait for the movie to be rendered
$movie->waitToFinish();
let movie = new Movie;
movie.setAPIKey(YOUR_API_KEY);
movie.set("resolution", "full-hd");
movie.set("quality", "high");
// Create the scenes of the movie
// Create SCENE 1
let scene1 = new Scene;
scene1.set("comment", "Scene #1");
scene1.addElement({
"type": "voice",
"text": "That's one small step for a man, <super-slow>one giant leap for mankind</super-slow>. <fast>Upon taking a \"small step\" onto the surface of the moon in 1969</fast>, Neil Armstrong uttered what would become <slow>one of history's most famous one-liners</slow>.",
"start": 1.5
});
movie.addScene(scene1);
// Finally, render the movie
movie.render();
// Wait for the movie to be rendered
movie.waitToFinish();
Expressing emotion
You can also add an emotion to the voice over by using tags.
{
"resolution": "full-hd",
"quality": "high",
"scenes": [
{
"comment": "Scene #1",
"elements": [
{
"type": "voice",
"voice": "en-US-AriaNeural",
"text": "<cheerful>\"That's remarkable! You're a genius!\"</cheerful> Mom said to her son.",
"start": 1.5
}
]
}
]
}
require 'vendor/autoload.php';
use JSON2Video\Movie;
use JSON2Video\Scene;
// Create and initialize the movie object
$movie = new Movie;
$movie->setAPIKey(YOUR_API_KEY);
$movie->resolution = 'full-hd';
$movie->quality = 'high';
// Create the scenes of the movie
// Create SCENE 1
$scene1 = new Scene;
$scene1->comment = 'Scene #1';
$scene1->addElement([
'type' => 'voice',
'voice' => 'en-US-AriaNeural',
'text' => '<cheerful>"That\'s remarkable! You\'re a genius!"</cheerful> Mom said to her son.',
'start' => 1.5
]);
$movie->addScene($scene1);
// Finally, render the movie
$movie->render();
// Wait for the movie to be rendered
$movie->waitToFinish();
let movie = new Movie;
movie.setAPIKey(YOUR_API_KEY);
movie.set("resolution", "full-hd");
movie.set("quality", "high");
// Create the scenes of the movie
// Create SCENE 1
let scene1 = new Scene;
scene1.set("comment", "Scene #1");
scene1.addElement({
"type": "voice",
"voice": "en-US-AriaNeural",
"text": "<cheerful>\"That's remarkable! You're a genius!\"</cheerful> Mom said to her son.",
"start": 1.5
});
movie.addScene(scene1);
// Finally, render the movie
movie.render();
// Wait for the movie to be rendered
movie.waitToFinish();
Using SSML
Finally, you can use SSML tags to express more complex nuances.
{
"resolution": "full-hd",
"quality": "high",
"scenes": [
{
"comment": "Scene #1",
"elements": [
{
"type": "voice",
"voice": "en-US-AriaNeural",
"text": "<mstts:express-as style=\"cheerful\">\"That's remarkable! You're a genius!\"</mstts:express-as><break time=\"600ms\" />Mom said to her son.",
"start": 1.5
}
]
}
]
}
require 'vendor/autoload.php';
use JSON2Video\Movie;
use JSON2Video\Scene;
// Create and initialize the movie object
$movie = new Movie;
$movie->setAPIKey(YOUR_API_KEY);
$movie->resolution = 'full-hd';
$movie->quality = 'high';
// Create the scenes of the movie
// Create SCENE 1
$scene1 = new Scene;
$scene1->comment = 'Scene #1';
$scene1->addElement([
'type' => 'voice',
'voice' => 'en-US-AriaNeural',
'text' => '<mstts:express-as style="cheerful">"That\'s remarkable! You\'re a genius!"</mstts:express-as><break time="600ms" />Mom said to her son.',
'start' => 1.5
]);
$movie->addScene($scene1);
// Finally, render the movie
$movie->render();
// Wait for the movie to be rendered
$movie->waitToFinish();
let movie = new Movie;
movie.setAPIKey(YOUR_API_KEY);
movie.set("resolution", "full-hd");
movie.set("quality", "high");
// Create the scenes of the movie
// Create SCENE 1
let scene1 = new Scene;
scene1.set("comment", "Scene #1");
scene1.addElement({
"type": "voice",
"voice": "en-US-AriaNeural",
"text": "<mstts:express-as style=\"cheerful\">\"That's remarkable! You're a genius!\"</mstts:express-as><break time=\"600ms\" />Mom said to her son.",
"start": 1.5
});
movie.addScene(scene1);
// Finally, render the movie
movie.render();
// Wait for the movie to be rendered
movie.waitToFinish();
Balancing music and voice volume
When you want to add music and narration to a video,
you typically need to adjust the volume so that the voice can be heard clearly.
The best option is to keep the voice at its original volume and reduce the
volume of the music.