Remark : This method always returns the static voice control client object. That is, if you call a method using one of voice control client objects, it affects other objects.
Return value:
VoiceControlClient The object to manage voice control
Exceptions:
WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type AbortError, if the operation cannot be finished properly.
Code example:
/* client1 and client2 refer the same object */
var client1 = tizen.voicecontrol.getVoiceControlClient();
var client2 = tizen.voicecontrol.getVoiceControlClient();
A language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code. For example, "ko_KR" for Korean, "en_US" for American English.
Exceptions:
WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var currentLanguage = client.getCurrentLanguage();
console.log("Current language is: " + currentLanguage);
type [optional][nullable]: Type of registered commands. The default value is "FOREGROUND"
Exceptions:
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var commands = [
new tizen.VoiceControlCommand("alpha"),
new tizen.VoiceControlCommand("bravo"),
new tizen.VoiceControlCommand("charlie")];
client.setCommandList(commands, "FOREGROUND");
type [optional][nullable]: Type of commands that should be unset. The default value is "FOREGROUND"
Exceptions:
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var commands = [
new tizen.VoiceControlCommand("alpha"),
new tizen.VoiceControlCommand("bravo"),
new tizen.VoiceControlCommand("charlie")];
client.setCommandList(commands, "FOREGROUND");
client.unsetCommandList("FOREGROUND");
addResultListener
Registers a listener for getting recognition result.
long addResultListener(VoiceControlResultCallback listener);
Since: 4.0
Parameters:
listener: Callback function to register
Return value:
long Identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var commands = [
new tizen.VoiceControlCommand("alpha"),
new tizen.VoiceControlCommand("bravo"),
new tizen.VoiceControlCommand("charlie")];
client.setCommandList(commands, "FOREGROUND");
var resultListenerCallback = function(event, list, result)
{
console.log("Result callback - event: " + event + ", result: " + result);
}
var id = client.addResultListener(resultListenerCallback);
console.log("Result listener[" + id + "] is created");
Output example:
Result listener[1] is created
Output example:
/* (When a user says "alpha") */
Result callback - event: SUCCESS, result: alpha
removeResultListener
Unregisters the listener.
void removeResultListener(long id);
Since: 4.0
Parameters:
id: Identifier used to clear the watch subscription
Exceptions:
WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var commands = [
new tizen.VoiceControlCommand("alpha"),
new tizen.VoiceControlCommand("bravo"),
new tizen.VoiceControlCommand("charlie")];
client.setCommandList(commands, "FOREGROUND");
var resultListenerCallback = function(event, list, result)
{
console.log("Result callback - event: " + event + ", result: " + result);
}
var id = client.addResultListener(resultListenerCallback);
client.removeResultListener(id);
addLanguageChangeListener
Registers a callback function to be called when current language is changed.
long addLanguageChangeListener(VoiceControlLanguageChangeCallback listener);
Since: 4.0
Parameters:
listener: Callback function to register
Return value:
long Identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type NotSupportedError, if this feature is not supported.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var languageChangeListenerCallback = function(previous, current)
{
console.log("Language change callback " + previous + "->" + current);
}
var id = client.addLanguageChangeListener(languageChangeListenerCallback);
console.log("Language change listener[" + id + "] is created");
Output example:
Language change listener[1] is created
Output example:
/* (When language is changed) */
Language change callback en_US->ko_KR
removeLanguageChangeListener
Unregisters the callback function.
void removeLanguageChangeListener(long id);
Since: 4.0
Parameters:
id: Identifier used to clear the watch subscription
Exceptions:
WebAPIException
with error type NotSupportedError, if this feature is not supported.
with error type AbortError, if the operation cannot be finished properly.
Code example:
var client = tizen.voicecontrol.getVoiceControlClient();
var languageChangeListenerCallback = function(previous, current)
{
console.log("Language change callback " + previous + "->" + current);;
}
var id = client.addLanguageChangeListener(languageChangeListenerCallback);
client.removeLanguageChangeListener(id);
release
Releases all resources.
void release();
Since: 4.0
Releases listeners and disconnects voice control service. You should call this method when you do not want to use voice control client instance any more. It is necessary to create new voice control client instance, if you want to use more after release.
Remark : If you call this method, all other VoiceControlClient objects are also released.
Exceptions:
WebAPIException
with error type AbortError, if the operation cannot be finished properly.
Code example:
/* Initialize the voice control client */
var client = tizen.voicecontrol.getVoiceControlClient();
var commands = [
new tizen.VoiceControlCommand("alpha"),
new tizen.VoiceControlCommand("bravo"),
new tizen.VoiceControlCommand("charlie")];
client.setCommandList(commands, "FOREGROUND");
var resultListenerCallback = function(event, list, result)
{
console.log("Result callback - event: " + event + ", result: " + result);
}
var id = client.addResultListener(resultListenerCallback);
/* Deinitialize the voice control client */
client.removeResultListener(id);
client.unsetCommandList("FOREGROUND");
/* After release() voice control does not work */
/* If you want to use voice control after release(), you should initialize the client again */
client.release();
2.4. VoiceControlCommand
The VoiceControlCommand defines interface used to create command you want to be recognized.
results: The spoken text (e.g. registered command text like "play", "stop", etc.)
3. Related Feature
You can check if this API is supported with tizen.systeminfo.getCapability() and decide enable/disable codes that need this API.
To guarantee that the voice control application runs on a device with speech control feature, declare the following feature requirements in the config file:
http://tizen.org/feature/speech.control
To guarantee that the voice control application runs on a device with microphone feature, declare the following feature requirements in the config file:
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.