Segment SDK

SpeechToText

Constructor
new SpeechToText()

SpeechToText constructor. This class helps to start voice recoginition to return text data.

Summary

Methods
startSpeechToText Request to start voice input / recognition to the system.
Type definitions
onsuccess Callback method that is invoked when speech has been successfully recognized
onerror Callback method that is invoked when speech has failed to be recognized

Methods

startSpeechToText(callbackObject)

Request to start voice input / recognition to the system.

Parameters
Name Type Description
callbackObject function Callback object

Properties
Name Type Description
onsuccess da.SpeechToText~onsuccess The callback function to be invoked when voice input is successfully recognized.
onerror da.SpeechToText~onerror The callback function to be invoked when the voice recognition fails.

Type definitions

onsuccess(result)

Type
function

Callback method that is invoked when speech has been successfully recognized

Parameters
Name Type Description
result Array.<string> Array of strings

onerror(error)

Type
function

Callback method that is invoked when speech has failed to be recognized

Parameters
Name Type Description
error Object Error object

Properties
Name Type Description
code number Error code
  • 900: voice input is canceled
  • 901: time over error
  • 902: network connection error
  • 903: result is empty
  • 904: can't recognized
  • 999: unidentified error
message string Error message. Above message is returned.