Class: WebspeechAudioInput

WebspeechAudioInput

mmir.env.media.WebspeechAudioInput

Classes

MicLevelsAnalysisStub

Members

protected,readonly_pluginName

Default Value:
  • "webspeechAudioInput"

private_prevResultString

field for storing the previous (main) recontion result (this is used for calculating "unstable" parts, see helper_extract_results)

privateaborted

privateactive

privatecurrentFailureCallbackfunction

privatecurrentSuccessCallbackfunction

privateDEFAULT_ALTERNATIVE_RESULTS

privatedefault_error_functionfunction

privateDEFAULT_LANGUAGE

private,constantEVENT_RESULT_FIELD

private,constantEVENT_SCORE_FIELD

privatefinal_recognition_result

privatehelper_error_handlerfunction

privateintermediate_results

privateloggermmir.tools.Logger

privatemax_error_retry

Maximal number of errors-in-a-row for trying to restart recognition in repeat-mode.
Default Value:
  • 5
See:
  • error_counter

privatemicLevelsImplFile

privatepluginExportswebspeechAudioInput

privaterecognitionSpeechRecognition

privaterecording

private,constantRESULT_TYPESEnum

Result types (returned by the native/Cordova plugin)

privateSpeechRecognitionImplSpeechRecognition

private,constantUNSTABLE_LIMIT

Methods

See:

privatedefault_error_function()

for debugging - NOTE use with caution, be removed in the future
See:
  • see Logger#getLevel

getRecognitionLanguages()

See:

privatehelper_error_handler(){Boolean}

default helper for error-events: determines, if RESTART is allowed/possible (in case of RECORDing mode), AND otherwise triggers the current failure-callbacks. SIDE-EFFECTS: sets private field aborted:=true if RESTART is NOT possible.
Returns:
Type Description
Boolean true, if the function could process the error (i.e. return false for unknown errors; these should be handled by the invoking code of this helper function)

privatehelper_extract_results()

create callback-arguments for ASR-result callback:
Returns:
Array with
		[	String result,
			Number score,
			String type ["INTERIM" | "FINAL" ],
			Array alternatives,         //OPTIONAL
			String unstable                      //OPTIONAL
		]
		
Start speech recognition with end-of-speech detection: the recognizer automatically tries to detect when speech has finished and triggers the status-callback accordingly with results.

NOTE: no end event, if recognize() is stopped via stopRecord()

See:
for debugging - NOTE use with caution, be removed in the future
Default Value:

asyncstartRecord(options, statusCallback, failureCallback)

Start speech recognition (without end-of-speech detection): after starting, the recognition continues until stopRecord is called.
Name Type Description
options PlainObject optional OPTIONAL options for Automatic Speech Recognition:
{
			  success: OPTIONAL Function, the status-callback (see arg statusCallback)
			, error: OPTIONAL Function, the error callback (see arg failureCallback)
			, language: OPTIONAL String, the language for recognition (if omitted, the current language setting is used)
			, intermediate: OTPIONAL Boolean, set true for receiving intermediate results (NOTE not all ASR engines may support intermediate results)
			, results: OTPIONAL Number, set how many recognition alternatives should be returned at most (NOTE not all ASR engines may support this option)
			, mode: OTPIONAL "search" | "dictation", set how many recognition alternatives should be returned at most (NOTE not all ASR engines may support this option)
			, eosPause: OTPIONAL "short" | "long", length of pause after speech for end-of-speech detection (NOTE not all ASR engines may support this option)
			, disableImprovedFeedback: OTPIONAL Boolean, disable improved feedback when using intermediate results (NOTE not all ASR engines may support this option)
		}
statusCallback function optional OPTIONAL callback function that is triggered when, recognition starts, text results become available, and recognition ends. The callback signature is:
				callback(
					text: String | "",
					confidence: Number | Void,
					status: "FINAL"|"INTERIM"|"INTERMEDIATE"|"RECORDING_BEGIN"|"RECORDING_DONE",
					alternatives: Array<{result: String, score: Number}> | Void,
					unstable: String | Void
				)
				
Usually, for status "FINAL" | "INTERIM" | "INTERMEDIATE" text results are returned, where
			  "INTERIM": an interim result, that might still change
			  "INTERMEDIATE": a stable, intermediate result
			  "FINAL": a (stable) final result, before the recognition stops
			
If present, the unstable argument provides a preview for the currently processed / recognized text.
NOTE that when using intermediate mode, status-calls with "INTERMEDIATE" may contain "final intermediate" results, too.
NOTE: if used in combination with options.success, this argument will supersede the options
failureCallback function optional OPTIONAL callback function that is triggered when an error occurred. The callback signature is: callback(error)
NOTE: if used in combination with options.error, this argument will supersede the options
See:
See: