Class OnlineVocalizer

ru.yandex.speechkit

java.lang.Object ⇽ OnlineVocalizer

public  class  OnlineVocalizer  implements Vocalizer

All Implemented Interfaces:
Vocalizer

Class for online speech synthesis and text-to-speech.

Responsible for sending text to the server and vocalizing synthesized speech. To notify of events, an object of the OnlineVocalizer class uses the VocalizerListener interface.

Note.

An object of the OnlineVocalizer class uses android.os.Handler for notifying subscribed listeners VocalizerListener. Therefore, listeners can only be created in a stream that has android.os.Looper, otherwise an exception will be thrown.

Nested Classes

Methods

synchronized voidcancel()

Interrupts the process of speech synthesis and vocalizing the synthesized speech.

synchronized voiddestroy()

Explicitly releases resources used by the component.

voidfinalize()
longgetChunkTimeoutMs()

Returns the maximum time to wait for each audio fragment, in milliseconds.

EmotiongetEmotion()

Returns an object of the Emotion class.

LanguagegetLanguage()

Returns an object of the Language class.

QualitygetQuality()

Returns the value of the quality of synthesized speech.

longgetRequestTimeoutMs()

Returns the maximum connection timeout, in milliseconds, after initiating a synthesis request.

floatgetServerRequestVolume()

Returns the volume that will be used at speech synthesis (not to be confused with the playback volume).

UniProxySessiongetSession()

Returns an object of the UniProxySession class that will be used for a network connection.

SoundFormatgetSoundFormat()

Returns the format of synthesized speech.

floatgetSpeed()

Returns the speed of synthesized speech.

VoicegetVoice()

Returns an object of the Voice class.

booleanisAutoPlay()

Returns the flag of speech playback (after synthesis) through the embedded player.

synchronized voidplay()

Starts the playback of the synthesized speech.

synchronized voidprepare()

Prepares an object of the Vocalizer class for speech synthesis.

synchronized voidsynthesize(@NonNull final String text, @NonNull final TextSynthesizingMode mode)

Starts the process of speech synthesis.

StringtoString()

Method Detail

cancel

public synchronized void cancel ()

Interrupts the process of speech synthesis and vocalizing the synthesized speech.

destroy

public synchronized void destroy ()

Explicitly releases resources used by the component.

Once the resources are released, no correct operation of Vocalizer is possible.

finalize

public void finalize ()

getChunkTimeoutMs

public long getChunkTimeoutMs ()

Returns the maximum time to wait for each audio fragment, in milliseconds.

Returns:

Maximum time to wait for each audio fragment.

getEmotion

public Emotion getEmotion ()

Returns an object of the Emotion class.

Returns:

Emotion of synthesized voice.

getLanguage

public Language getLanguage ()

Returns an object of the Language class.

Returns:

Language of synthesized speech.

getQuality

public Quality getQuality ()

Returns the value of the quality of synthesized speech.

Returns:

Quality of synthesized speech.

getRequestTimeoutMs

public long getRequestTimeoutMs ()

Returns the maximum connection timeout, in milliseconds, after initiating a synthesis request.

Returns:

Maximum connection timeout after initiating a synthesis request.

getServerRequestVolume

public float getServerRequestVolume ()

Returns the volume that will be used at speech synthesis (not to be confused with the playback volume).

Returns:

The volume that will be used at speech synthesis (not to be confused with the playback volume).

getSession

public UniProxySession getSession ()

Returns an object of the UniProxySession class that will be used for a network connection.

Returns:

An object of the UniProxySession class that will be used for a network connection.

getSoundFormat

public SoundFormat getSoundFormat ()

Returns the format of synthesized speech.

Returns:

Format of synthesized speech.

getSpeed

public float getSpeed ()

Returns the speed of synthesized speech.

Returns:

Speed of synthesized speech.

getVoice

public Voice getVoice ()

Returns an object of the Voice class.

Returns:

Voice used for synthesized speech.

isAutoPlay

public boolean isAutoPlay ()

Returns the flag of speech playback (after synthesis) through the embedded player.

Returns:

Flag of speech playback (after synthesis) through the embedded player.

play

public synchronized void play ()

Starts the playback of the synthesized speech.

This method should be called to start playing the synthesized audio if isAutoPlay () is set to false.

prepare

public synchronized void prepare ()

Prepares an object of the Vocalizer class for speech synthesis.

Makes preparation for speech synthesis in advance. If the method is not called explicitly, it is called automatically in the synthesize(String, TextSynthesizingMode) method. Asynchronous execution.

synthesize

public synchronized void synthesize (@NonNull final String text, @NonNull final TextSynthesizingMode mode)

Starts the process of speech synthesis.

Can be called multiple times for a single object of the Vocalizer class. If speech synthesis is not completed when the method is called again, the object's behavior will be determined by the mode parameter. Asynchronous execution.
Parameters:
text

The text for synthesis.

mode

The behavior of an object of the Vocalizer class if the previously launched speech synthesis process was not completed.

toString

public String toString ()