Goal - Make Pepper talk.
// Create a phrase.
val phrase: Phrase = Phrase("Hello")
// Build the action.
val say: Say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.build()
// Run the action synchronously.
say.run()
// Create a phrase.
Phrase phrase = new Phrase("Hello");
// Build the action.
Say say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.build();
// Run the action synchronously.
say.run();
Typical usage - A pre-established speech, not driven by verbal interaction.
To set what Pepper should say, create a Phrase containing the group of words to pronounce, and build the action with it:
val phrase: Phrase = Phrase("Hello")
val say: Say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.build()
say.run()
Phrase phrase = new Phrase("Hello");
Say say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.build();
say.run();
By default, Pepper doesn’t stay motionless while speaking, he makes relevant gestures according to what he is saying: this is his body language.
You can choose to keep this behaviour or to disable it with a BodyLanguageOption
.
To disable the body language, use BodyLanguageOption.DISABLED
:
val say: Say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.withBodyLanguageOption(BodyLanguageOption.DISABLED)
.build()
say.run()
Say say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.withBodyLanguageOption(BodyLanguageOption.DISABLED)
.build();
say.run();
See also API doc: BodyLanguageOption.
By default Pepper uses his Preferred Language.
To set a different language, use a Locale
.
For example, to make Pepper speak French, use Language.FRENCH
and Region.FRANCE
:
val locale: Locale = Locale(Language.FRENCH, Region.FRANCE);
val say: Say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.withLocale(locale)
.build()
say.run()
Locale locale = new Locale(Language.FRENCH, Region.FRANCE);
Say say = SayBuilder.with(qiContext)
.withPhrase(phrase)
.withLocale(locale)
.build();
say.run();
See also API doc: Locale.
Someone selects a location on the tablet and expects Pepper to give him/her some information about this location.
val locationName: String = ...
val locationDescription: String = ...
val namePhrase: Phrase = Phrase("This location is $locationName")
val sayName: Say = SayBuilder.with(qiContext)
.withPhrase(namePhrase)
.build()
val descriptionPhrase: Phrase = Phrase(locationDescription);
val sayDescription: Say = SayBuilder.with(qiContext)
.withPhrase(descriptionPhrase)
.build()
sayName.run()
sayDescription.run()
String locationName = ...;
String locationDescription = ...;
Phrase namePhrase = new Phrase("This location is " + locationName);
Say sayName = SayBuilder.with(qiContext)
.withPhrase(namePhrase)
.build();
Phrase descriptionPhrase = new Phrase(locationDescription);
Say sayDescription = SayBuilder.with(qiContext)
.withPhrase(descriptionPhrase)
.build();
sayName.run();
sayDescription.run();