public class Speech
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static Speech |
getInstance()
Gets speech recognition instance.
|
java.util.Locale |
getSpeechToTextLanguage()
Gets the locale used for speech recognition.
|
void |
getSupportedSpeechToTextLanguages(SupportedLanguagesListener listener)
Gets the list of the supported speech to text languages on this device
|
java.util.List<android.speech.tts.Voice> |
getSupportedTextToSpeechVoices()
Gets the list of the supported Text to Speech languages on this device
|
android.speech.tts.Voice |
getTextToSpeechVoice()
Gets the current voice used for text to speech.
|
static Speech |
init(android.content.Context context)
Initializes speech recognition.
|
static Speech |
init(android.content.Context context,
java.lang.String callingPackage)
Initializes speech recognition.
|
static Speech |
init(android.content.Context context,
java.lang.String callingPackage,
android.speech.tts.TextToSpeech.OnInitListener onInitListener) |
static Speech |
init(android.content.Context context,
java.lang.String callingPackage,
android.speech.tts.TextToSpeech.OnInitListener onInitListener,
SpeechRecognitionEngine speechRecognitionEngine,
TextToSpeechEngine textToSpeechEngine) |
boolean |
isListening()
Check if voice recognition is currently active.
|
boolean |
isSpeaking()
Check if text to speak is currently speaking.
|
void |
say(java.lang.String message)
Uses text to speech to transform a written message into a sound.
|
void |
say(java.lang.String message,
TextToSpeechCallback callback)
Uses text to speech to transform a written message into a sound.
|
Speech |
setAudioStream(int audioStream)
Sets the audio stream type.
|
Speech |
setGetPartialResults(boolean getPartialResults)
Set whether partial results should be returned by the recognizer as the user speaks
(default is true).
|
Speech |
setLocale(java.util.Locale locale)
Sets text to speech and recognition language.
|
Speech |
setPreferOffline(boolean preferOffline)
Set whether to only use an offline speech recognition engine.
|
Speech |
setStopListeningAfterInactivity(long milliseconds)
Sets the idle timeout after which the listening will be automatically stopped.
|
Speech |
setTextToSpeechPitch(float pitch)
Sets the speech pitch for the TextToSpeech engine.
|
Speech |
setTextToSpeechQueueMode(int mode)
Sets the text to speech queue mode.
|
Speech |
setTextToSpeechRate(float rate)
Sets the speech rate.
|
Speech |
setTransitionMinimumDelay(long milliseconds)
Sets the minimum interval between start/stop events.
|
Speech |
setVoice(android.speech.tts.Voice voice)
Sets the voice for the TextToSpeech engine.
|
void |
shutdown()
Must be called inside Activity's onDestroy.
|
void |
startListening(SpeechDelegate delegate)
Starts voice recognition.
|
void |
startListening(SpeechProgressView progressView,
SpeechDelegate delegate)
Starts voice recognition.
|
void |
stopListening()
Stops voice recognition listening.
|
void |
stopTextToSpeech()
Stops text to speech.
|
public static Speech init(android.content.Context context)
context - application contextpublic static Speech init(android.content.Context context, java.lang.String callingPackage)
context - application contextcallingPackage - The extra key used in an intent to the speech recognizer for
voice search. Not generally to be used by developers.
The system search dialog uses this, for example, to set a calling
package for identification by a voice search API.
If this extra is set by anyone but the system process,
it should be overridden by the voice search implementation.
By passing null or empty string (which is the default) you are
not overriding the calling packagepublic static Speech init(android.content.Context context, java.lang.String callingPackage, android.speech.tts.TextToSpeech.OnInitListener onInitListener)
public static Speech init(android.content.Context context, java.lang.String callingPackage, android.speech.tts.TextToSpeech.OnInitListener onInitListener, SpeechRecognitionEngine speechRecognitionEngine, TextToSpeechEngine textToSpeechEngine)
public void shutdown()
public static Speech getInstance()
public void startListening(SpeechDelegate delegate) throws SpeechRecognitionNotAvailable, GoogleVoiceTypingDisabledException
delegate - delegate which will receive speech recognition events and statusSpeechRecognitionNotAvailable - when speech recognition is not available on the deviceGoogleVoiceTypingDisabledException - when google voice typing is disabled on the devicepublic void startListening(SpeechProgressView progressView, SpeechDelegate delegate) throws SpeechRecognitionNotAvailable, GoogleVoiceTypingDisabledException
progressView - view in which to draw speech animationdelegate - delegate which will receive speech recognition events and statusSpeechRecognitionNotAvailable - when speech recognition is not available on the deviceGoogleVoiceTypingDisabledException - when google voice typing is disabled on the devicepublic void stopListening()
public boolean isListening()
public boolean isSpeaking()
public void say(java.lang.String message)
message - message to playpublic void say(java.lang.String message,
TextToSpeechCallback callback)
message - message to playcallback - callback which will receive progress status of the operationpublic void stopTextToSpeech()
public Speech setPreferOffline(boolean preferOffline)
preferOffline - true to prefer offline engine, false to use either one of the twopublic Speech setGetPartialResults(boolean getPartialResults)
getPartialResults - true to get also partial recognition results, false otherwisepublic Speech setLocale(java.util.Locale locale)
locale - new localepublic Speech setTextToSpeechRate(float rate)
rate - Speech rate. 1.0 is the normal speech rate, lower values slow down the speech
(0.5 is half the normal speech rate), greater values accelerate it
(2.0 is twice the normal speech rate).public Speech setVoice(android.speech.tts.Voice voice)
voice - Speech voice.public Speech setTextToSpeechPitch(float pitch)
pitch - Speech pitch. 1.0 is the normal pitch, lower values lower the tone of the
synthesized voice, greater values increase it.public Speech setStopListeningAfterInactivity(long milliseconds)
milliseconds - timeout in millisecondspublic Speech setTransitionMinimumDelay(long milliseconds)
milliseconds - minimum interval betweeb state change in millisecondspublic Speech setTextToSpeechQueueMode(int mode)
mode - It can be either TextToSpeech.QUEUE_ADD or TextToSpeech.QUEUE_FLUSH.public Speech setAudioStream(int audioStream)
audioStream - A constant from AudioManager.
e.g. AudioManager.STREAM_VOICE_CALLpublic void getSupportedSpeechToTextLanguages(SupportedLanguagesListener listener)
listener - listner which will receive the resultspublic java.util.List<android.speech.tts.Voice> getSupportedTextToSpeechVoices()
public java.util.Locale getSpeechToTextLanguage()
public android.speech.tts.Voice getTextToSpeechVoice()