Modules. ASR

ASR module provides speech recognition capabilities, call audio can be sent to the ASR instance. Language or dictionary should be passed to createASR function.

Add the following line to your scenario code to use the module:

 require(Modules.ASR);

All functions, events and classes of the module can be used only after this line.

Events

ASREvents.ASRError

The event is triggered in case of problems during the recognition process

Properties
  • asr: ASR

    ASR instance that generated the event

  • error: string

    Error message

ASREvents.CaptureStarted

The event is triggered after ASR detected voice input and started collecting audio data for ASR

Properties
  • asr: ASR

    ASR instance that generated the event

ASREvents.InterimResult

The event is triggered when interim recognition result received from ASR. Note that event could be only triggered if the appropriate parameter interimResults is true.

Properties
  • asr: ASR

    ASR instance that generated the event

  • text: string

    Recognition result

ASREvents.Result

The event is triggered when recognition result received from ASR

Properties
  • asr: ASR

    ASR instance that generated the event

  • confidence: number

    Recognition confidence in 0..100 Range (100 means full confidence, 0 - not confident at all)

  • text: string

    Recognition result

ASREvents.SpeechCaptured

The event is triggered after ASR captured audio data, before recognition process

Properties
  • asr: ASR

    ASR instance that generated the event

ASREvents.Started

The event is triggered after ASR instance was created

Properties
  • asr: ASR

    ASR instance that generated the event

ASREvents.Stopped

The event is triggered after ASR stop function call

Properties
  • asr: ASR

    ASR that generated the event

Functions

VoxEngine.createASR(params)

ASR

Creates new speech recognizer and starts the recognition.

Sources can later be attached using Call.sendMediaTo() etc.
Example

 require(Modules.ASR);

 var asr = VoxEngine.createASR({lang:ASRLanguage.ENGLISH_US, dict:["John", "Mike", "Matthew", "Cary"]});
 asr.addEventListener(ASREvents.Result, function(asrevent) {
		asr.stop();
	    if (asrevent.confidence > 50)  {
	    	call.say("Calling "+asrevent.text, Language.US_ENGLISH_FEMALE);
	    	call.addEventListener(CallEvents.PlaybackFinished, VoxEngine.terminate);
	    }
	});
 call.sendMediaTo(asr);
Parameters
  • params: ASRParameters

    ASR parameters. IMPORTANT: the lang parameter is required, the other parameters are optional.

Returns

Constants

ASRDictionary.ADDRESS_RU

ASR Russian addresses dictionary

ASRDictionary.ADDRESS_TR

ASR Turkish addresses dictionary

ASRDictionary.DATE_RU

ASR Russian Date dictionary

ASRDictionary.ECOMMERCE

ASR Buying dictionary

ASRDictionary.MUSIC

ASR Music dictionary

ASRDictionary.NAMES_RU

ASR Russian Names dictionary

ASRDictionary.NOTES

ASR Notes dictionary

ASRDictionary.NUMBERS_RU

ASR Russian Numbers dictionary

ASRDictionary.QUESTIONNAIRE_RU

ASR Russian Questionnaire dictionary

ASRDictionary.SEARCH_QUERIES

ASR Queries dictionary

ASRLanguage.AFRIKAANS_ZA

Afrikaans (South Africa)

ASRLanguage.AMHARIC_ET

Amharic (Ethiopia)

ASRLanguage.ARABIC_AE

Arabic (U.A.E.)

ASRLanguage.ARABIC_BH

Arabic (Bahrain)

ASRLanguage.ARABIC_DZ

Arabic (Algeria)

ASRLanguage.ARABIC_IL

Arabic (Israel)

ASRLanguage.ARABIC_JO

Arabic (Jordan)

ASRLanguage.ARABIC_KW

Arabic (Kuwait)

ASRLanguage.ARABIC_LB

Arabic (Lebanon)

ASRLanguage.ARABIC_MA

Arabic (Morocco)

ASRLanguage.ARABIC_PS

Arabic (Palestinian)

ASRLanguage.ARABIC_SA

Arabic (Saudi Arabia)

ASRLanguage.ARABIC_TN

Arabic (Tunisia)

ASRLanguage.ARMENIAN_AM

Armenian (Armenia)

ASRLanguage.AZERBAIJANI_AZ

Azerbaijani (Azerbaijan)

ASRLanguage.BENGALI_BD

Bengali (Bangladesh)

ASRLanguage.BENGALI_IN

Bengali (India)

ASRLanguage.BULGARIAN_BG

Bulgarian (Bulgaria)

ASRLanguage.CANTONESE_HK

Cantonese, Traditional script, Hong Kong SAR

ASRLanguage.CATALAN_ES

Catalan (Catalan)

ASRLanguage.CHINESE_CN

Chinese (People's Republic of China)

ASRLanguage.CHINESE_HK

Chinese (Hong Kong S.A.R.)

ASRLanguage.CHINESE_TW

Chinese (Taiwan)

ASRLanguage.CROATIAN_HR

Croatian (Croatia)

ASRLanguage.CZECH_CZ

Czech (Czech Republic)

ASRLanguage.DANISH_DK

Danish (Denmark)

ASRLanguage.DUTCH_NL

Dutch (Netherlands)

ASRLanguage.ENGLISH_AU

English (Australia)

ASRLanguage.ENGLISH_CA

English (Canada)

ASRLanguage.ENGLISH_GH

English (Ghana)

ASRLanguage.ENGLISH_IE

English (Ireland)

ASRLanguage.ENGLISH_IN

English (India)

ASRLanguage.ENGLISH_KE

English (Kenya)

ASRLanguage.ENGLISH_NG

English (Nigeria)

ASRLanguage.ENGLISH_NZ

English (New Zealand)

ASRLanguage.ENGLISH_PH

English (Philippines)

ASRLanguage.ENGLISH_TZ

English (Tanzania)

ASRLanguage.ENGLISH_UK

English (United Kingdom)

ASRLanguage.ENGLISH_US

English (United States)

ASRLanguage.ENGLISH_ZA

English (South Africa)

ASRLanguage.FILIPINO_PH

Filipino (Philippines)

ASRLanguage.FINNISH_FI

Finnish (Finland)

ASRLanguage.FRENCH_CA

French (Canada)

ASRLanguage.FRENCH_FR

French (France)

ASRLanguage.GALICIAN_ES

Galician (Spain)

ASRLanguage.GEORGIAN_GE

Georgian (Georgia)

ASRLanguage.GERMAN_DE

German (Germany)

ASRLanguage.GREEK_GR

Greek (Greece)

ASRLanguage.GUJARATI_IN

Gujarati (India)

ASRLanguage.HEBREW_IL

Hebrew (Israel)

ASRLanguage.HUNGARIAN_HU

Hungarian (Hungary)

ASRLanguage.ICELANDIC_IS

Icelandic (Iceland)

ASRLanguage.INDONESIAN_ID

Indonesian (Indonesia)

ASRLanguage.ITALIAN_IT

Italian (Italy)

ASRLanguage.JAPANESE_JP

Japanese (Japan)

ASRLanguage.JAVANESE_ID

Javanese (Indonesia)

ASRLanguage.KANNADA_IN

Kannada (India)

ASRLanguage.KHMER_KH

Khmer (Cambodia)

ASRLanguage.LATVIAN_LV

Latvian (Latvia)

ASRLanguage.LITHUANIAN_LT

Lithuanian (Lithuania)

ASRLanguage.MALAYALAM_IN

Malayalam (India)

ASRLanguage.MALAYSIA_MY

Malay (Malaysia)

ASRLanguage.MARATHI_IN

Marathi (India)

ASRLanguage.NORWEGIAN_NO

Norwegian (Norway)

ASRLanguage.POLISH_PL

Polish (Poland)

ASRLanguage.PORTUGUESE_BR

Portuguese (Brazil)

ASRLanguage.PORTUGUES_PT

Portuguese (Portugal)

ASRLanguage.ROMANIAN_RO

Romanian (Romania)

ASRLanguage.RUSSIAN_RU

Russian (Russia)

ASRLanguage.SINHALA_LK

Sinhala (Srilanka)

ASRLanguage.SLOVAK_SK

Slovak (Slovakia)

ASRLanguage.SLOVENIAN_SL

Slovenian (Slovenia)

ASRLanguage.SPANISH_AR

Spanish (Argentina)

ASRLanguage.SPANISH_BO

Spanish (Bolivia)

ASRLanguage.SPANISH_CL

Spanish (Chile)

ASRLanguage.SPANISH_CO

Spanish (Colombia)

ASRLanguage.SPANISH_CR

Spanish (Costa Rica)

ASRLanguage.SPANISH_DO

Spanish (Republican Dominican)

ASRLanguage.SPANISH_EC

Spanish (Ecuador)

ASRLanguage.SPANISH_ES

Spanish (Spain)

ASRLanguage.SPANISH_GT

Spanish (Guatemala)

ASRLanguage.SPANISH_HN

Spanish (Honduras)

ASRLanguage.SPANISH_MX

Spanish (Mexico)

ASRLanguage.SPANISH_NI

Spanish (Nicaragua)

ASRLanguage.SPANISH_PA

Spanish (Panama)

ASRLanguage.SPANISH_PR

Spanish (Puerto Rico)

ASRLanguage.SPANISH_PY

Spanish (Paraguay)

ASRLanguage.SPANISH_SV

Spanish (El Salvador)

ASRLanguage.SPANISH_US

Spanish (Estados Unidos)

ASRLanguage.SPANISH_UY

Spanish (Uruguay)

ASRLanguage.SPANISH_VE

Spanish (Venezuela)

ASRLanguage.SUNDANESE_ID

Sundanese (Indonesia)

ASRLanguage.SWAHILI_KE

Swahili (Kenya)

ASRLanguage.SWAHILI_TZ

Swahili (Tanzania)

ASRLanguage.SWEDISH_SE

Swedish (Sweden)

ASRLanguage.TAMIL_LK

Tamil (Sri Lanka)

ASRLanguage.TAMIL_MY

Tamil (Malaysia)

ASRLanguage.TAMIL_SG

Tamil (Singapore)

ASRLanguage.THAI_TH

Thai (Thailand)

ASRLanguage.TURKISH_TR

Turkish (Turkey)

ASRLanguage.UKRAINIAN_UA

Ukrainian (Ukraine)

ASRLanguage.URDU_PK

Urdu (Pakistan)

ASRLanguage.VIETNAMESE_VN

Vietnamese (Viet Nam)

ASRLanguage.ZULU_ZA

Zulu (South Africa)

Example

 require(Modules.ASR);

 var call,
 asr;

 // Inbound call
 VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
		
		call = e.call;
		call.answer();
		call.addEventListener(CallEvents.Connected, handleCallConnected);
		call.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);

	});

 // CallConnected event handler
 function handleCallConnected(callevent) {
		// Play prompt
		call.say("Hi, thanks for calling us! Please choose a color you like - red, blue, yellow or green ", Language.US_ENGLISH_FEMALE);
		// Init ASR - expect US English input and explicitly specified custom dictionary
		asr = VoxEngine.createASR(ASRLanguage.ENGLISH_US, ["red", "blue", "yellow", "green"]);
		// Handle ASREvents.CaptureStarted (fired when system detects voice input and start collecting data for ASR)
		asr.addEventListener(ASREvents.CaptureStarted, function(e) {
				call.stopPlayback();
			});
		// Handle recognition result
		asr.addEventListener(ASREvents.Result, function(asrevent) {
			asr.stop();
		    call.say("You've chosen "+asrevent.text+" color. Confidence is "+asrevent.confidence, Language.US_ENGLISH_FEMALE);
		    call.addEventListener(CallEvents.PlaybackFinished, VoxEngine.terminate);
		});
		// Send call media to ASR instance
		call.sendMediaTo(asr);
	}