com.supermap.mapping.speech
Class SpeechManager
- java.lang.Object
-
- com.supermap.mapping.speech.SpeechManager
-
public class SpeechManager extends java.lang.Object
The SpeechManager class Doesn't support multi-threads.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
cancel()
Cancels the current function with the function.boolean
destroy()
Before calling the function, please ensure the current status is off session, otherwise, the function will try to cancel the current session and return false, and the Destroy is failed.static SpeechManager
getInstance(android.content.Context context)
Gets an instance of the SpeechManager classstatic void
init(android.content.Context context)
Initializes the speech SDK component (which only can be called in the host process), so calling it once when starting the applocation program is enough.boolean
isListening()
Gets whether the current SDK has a session via the function.void
setAudioPath(java.lang.String path)
Sets the audio storage path: (the supported format is wav) With the parameter, an audio file will be saved in local after completing the recognization It is not required Default: null (no audio files are saved) Value range: valid file paths (absolute or relative path with the file name) For example: Environment.getExternalStorageDirectory() + "/msc/speech.wav"void
setIsPunctuation(boolean isPunctuation)
Sets whether to return punctuations, true means Yes and False means novoid
setVAD_BOS_Time(int time)
Set the end before starting speaking: the over time, if users do not speak anything for the specified time, it will be taken as over time.void
setVAD_EOS_Time(int time)
Sets the finished end that is time using to stop recording when the user stops speaking for the specified time It is not required Default value: Write and listen: 1800, other: 700 Value range: [0, 10000]void
startListening(IntelligentSpeechListener listener)
Calls the function to begin to speech Currently, the SDK does not support multi-processes, and so if the funciton is called to start a session, the function can not be called again until the session is finished.void
stopListening()
Tells SDK with the function that all speech has been recorded.
-
-
-
Method Detail
-
init
public static void init(android.content.Context context)
Initializes the speech SDK component (which only can be called in the host process), so calling it once when starting the applocation program is enough. Suggests calling it in the program entry. The Application should be registered in the Mainifest if calling initialization in the Application Note: If the interface is called in a non-host process, the initialization will be failed!- Parameters:
context
- Application context.
-
getInstance
public static SpeechManager getInstance(android.content.Context context)
Gets an instance of the SpeechManager class- Parameters:
context
- The context.- Returns:
- If context is null, returns null.
-
isListening
public boolean isListening()
Gets whether the current SDK has a session via the function. The application layer checks whether a new session can be started via the function. After calling the stopListening(), if the session does not have any error or return the last result, the current status is still in a session, that is the function will return true. If calling cancel() to cancel the session, the current status will be off session.- Returns:
- the session status, true: in session; false: off session
-
destroy
public boolean destroy()
Before calling the function, please ensure the current status is off session, otherwise, the function will try to cancel the current session and return false, and the Destroy is failed. And please recall the function after the current session is canceled. When the funtion returns true, the Destroy operation is successful. And the instance created before can not be used again. If you need a new instance, please create one with the function getInstance(Context context).- Returns:
- true: successful; false: failed
-
startListening
public void startListening(IntelligentSpeechListener listener)
Calls the function to begin to speech Currently, the SDK does not support multi-processes, and so if the funciton is called to start a session, the function can not be called again until the session is finished. If setting related parameters are required, please set them before calling the function The current session can be canceled with cancel().- Parameters:
listener
- Listener.
-
stopListening
public void stopListening()
Tells SDK with the function that all speech has been recorded. After calling the function, the recorded audio are continued to upload to the server, and the result will not be turned back immediately. If you want to cancel the session, please refer to the function cancel(). When the application call the function to finish recording, SDK will not recall onEndOfSpeech(), in contrast, when SDK recalls onEndOfSpeech(), the application do not have to call the function to notice SDK stopping recording.
-
cancel
public void cancel()
Cancels the current function with the function. When the session is canceled, the current session is finished, and results that are not returned will not be returned.
-
setVAD_BOS_Time
public void setVAD_BOS_Time(int time)
Set the end before starting speaking: the over time, if users do not speak anything for the specified time, it will be taken as over time. It is not required Default value: Write and listen: 5000, other: 4000 Value range: [1000, 10000]- Parameters:
time
- the front end timeout
-
setVAD_EOS_Time
public void setVAD_EOS_Time(int time)
Sets the finished end that is time using to stop recording when the user stops speaking for the specified time It is not required Default value: Write and listen: 1800, other: 700 Value range: [0, 10000]- Parameters:
time
- the finished end timeout
-
setAudioPath
public void setAudioPath(java.lang.String path)
Sets the audio storage path: (the supported format is wav) With the parameter, an audio file will be saved in local after completing the recognization It is not required Default: null (no audio files are saved) Value range: valid file paths (absolute or relative path with the file name) For example: Environment.getExternalStorageDirectory() + "/msc/speech.wav"- Parameters:
path
- The audio path
-
setIsPunctuation
public void setIsPunctuation(boolean isPunctuation)
Sets whether to return punctuations, true means Yes and False means no- Parameters:
isPunctuation
- Whether to return punctuations.
-
-