SpeechSynthesizer Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. SpeechSynthesizer
- com.
Implements
public class SpeechSynthesizer
implements java.lang.AutoCloseable
Performs speech synthesis to speaker, file, or other audio output streams, and gets synthesized audio as result. Note: close() must be called in order to release underlying resources held by the object. Updated in version 1.16.0
Field Summary
Modifier and Type | Field and Description |
---|---|
final
Event |
BookmarkReached
Defines event handler for bookmark reached event. |
final
Event |
SynthesisCanceled
Defines event handler for synthesis canceled event. |
final
Event |
SynthesisCompleted
Defines event handler for synthesis completed event. |
final
Event |
SynthesisStarted
Defines event handler for synthesis started event. |
final
Event |
Synthesizing
Defines event handler for synthesizing event. |
final
Event |
VisemeReceived
Defines event handler for viseme received event. |
final
Event |
WordBoundary
Defines event handler for word boundary event. |
Constructor Summary
Constructor | Description |
---|---|
SpeechSynthesizer(EmbeddedSpeechConfig embeddedSpeechConfig) |
Creates a new instance of Speech Synthesizer for embedded speech synthesis. |
SpeechSynthesizer(EmbeddedSpeechConfig embeddedSpeechConfig, AudioConfig audioConfig) |
Creates a new instance of Speech Synthesizer for embedded speech synthesis. |
SpeechSynthesizer(HybridSpeechConfig hybridSpeechConfig) |
Creates a new instance of Speech Synthesizer for hybrid speech synthesis. |
SpeechSynthesizer(HybridSpeechConfig hybridSpeechConfig, AudioConfig audioConfig) |
Creates a new instance of Speech Synthesizer for hybrid speech synthesis. |
SpeechSynthesizer(SpeechConfig speechConfig) |
Creates a new instance of Speech Synthesizer. |
SpeechSynthesizer(SpeechConfig speechConfig, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig, AudioConfig audioConfig) |
Creates a new instance of Speech Synthesizer. |
SpeechSynthesizer(SpeechConfig speechConfig, AudioConfig audioConfig) |
Creates a new instance of Speech Synthesizer. |
Method Summary
Modifier and Type | Method and Description |
---|---|
Speech |
SpeakSsml(String ssml)
Execute the speech synthesis on SSML, synchronously. |
java.util.concurrent.Future<Speech |
SpeakSsmlAsync(String ssml)
Execute the speech synthesis on SSML, asynchronously. |
Speech |
SpeakText(String text)
Execute the speech synthesis on plain text, synchronously. |
java.util.concurrent.Future<Speech |
SpeakTextAsync(String text)
Execute the speech synthesis on plain text, asynchronously. |
Speech |
StartSpeakingSsml(String ssml)
Start the speech synthesis on SSML, synchronously. |
java.util.concurrent.Future<Speech |
StartSpeakingSsmlAsync(String ssml)
Start the speech synthesis on SSML, asynchronously. |
Speech |
StartSpeakingText(String text)
Start the speech synthesis on plain text, synchronously. |
java.util.concurrent.Future<Speech |
StartSpeakingTextAsync(String text)
Start the speech synthesis on plain text, asynchronously. |
java.util.concurrent.Future<java.lang.Void> |
StopSpeakingAsync()
Stop the synthesis, asynchronously. |
void |
close()
Dispose of associated resources. |
java.lang.String |
getAuthorizationToken()
Gets the authorization token used to communicate with the service. |
Safe |
getImpl()
INTERNAL |
Property |
getProperties()
The collection of properties and their values defined for this Speech |
java.util.concurrent.Future<Synthesis |
getVoicesAsync()
Get the available voices, asynchronously. |
java.util.concurrent.Future<Synthesis |
getVoicesAsync(String locale)
Get the available voices, asynchronously. |
void |
setAuthorizationToken(String token)
Sets the authorization token used to communicate with the service. |
Methods inherited from java.lang.Object
Field Details
BookmarkReached
public final EventHandlerImpl
Defines event handler for bookmark reached event. Added in version 1.16.0
SynthesisCanceled
public final EventHandlerImpl
Defines event handler for synthesis canceled event.
SynthesisCompleted
public final EventHandlerImpl
Defines event handler for synthesis completed event.
SynthesisStarted
public final EventHandlerImpl
Defines event handler for synthesis started event.
Synthesizing
public final EventHandlerImpl
Defines event handler for synthesizing event.
VisemeReceived
public final EventHandlerImpl
Defines event handler for viseme received event. Added in version 1.16.0
WordBoundary
public final EventHandlerImpl
Defines event handler for word boundary event.
Constructor Details
SpeechSynthesizer
public SpeechSynthesizer(EmbeddedSpeechConfig embeddedSpeechConfig)
Creates a new instance of Speech Synthesizer for embedded speech synthesis. Uses the default speaker on the system for audio output. Added in version 1.19.0
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(EmbeddedSpeechConfig embeddedSpeechConfig, AudioConfig audioConfig)
Creates a new instance of Speech Synthesizer for embedded speech synthesis. If audioConfig is null, there is no audio output. Added in version 1.19.0
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(HybridSpeechConfig hybridSpeechConfig)
Creates a new instance of Speech Synthesizer for hybrid speech synthesis. Uses the default speaker on the system for audio output.
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(HybridSpeechConfig hybridSpeechConfig, AudioConfig audioConfig)
Creates a new instance of Speech Synthesizer for hybrid speech synthesis. If audioConfig is null, there is no audio output.
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(SpeechConfig speechConfig)
Creates a new instance of Speech Synthesizer. Uses the default speaker on the system for audio output.
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(SpeechConfig speechConfig, AutoDetectSourceLanguageConfig autoDetectSourceLangConfig, AudioConfig audioConfig)
Creates a new instance of Speech Synthesizer.
Parameters:
SpeechSynthesizer
public SpeechSynthesizer(SpeechConfig speechConfig, AudioConfig audioConfig)
Creates a new instance of Speech Synthesizer. If audioConfig is null, there is no audio output.
Parameters:
Method Details
SpeakSsml
public SpeechSynthesisResult SpeakSsml(String ssml)
Execute the speech synthesis on SSML, synchronously.
Parameters:
Returns:
SpeakSsmlAsync
public Future
Execute the speech synthesis on SSML, asynchronously.
Parameters:
Returns:
SpeakText
public SpeechSynthesisResult SpeakText(String text)
Execute the speech synthesis on plain text, synchronously.
Parameters:
Returns:
SpeakTextAsync
public Future
Execute the speech synthesis on plain text, asynchronously.
Parameters:
Returns:
StartSpeakingSsml
public SpeechSynthesisResult StartSpeakingSsml(String ssml)
Start the speech synthesis on SSML, synchronously.
Parameters:
Returns:
StartSpeakingSsmlAsync
public Future
Start the speech synthesis on SSML, asynchronously.
Parameters:
Returns:
StartSpeakingText
public SpeechSynthesisResult StartSpeakingText(String text)
Start the speech synthesis on plain text, synchronously.
Parameters:
Returns:
StartSpeakingTextAsync
public Future
Start the speech synthesis on plain text, asynchronously.
Parameters:
Returns:
StopSpeakingAsync
public Future
Stop the synthesis, asynchronously. This method will stop the playback and clear the unread data in PullAudioOutputStream. Added in version 1.14.0
Returns:
close
public void close()
Dispose of associated resources.
getAuthorizationToken
public String getAuthorizationToken()
Gets the authorization token used to communicate with the service.
Returns:
getImpl
getProperties
public PropertyCollection getProperties()
The collection of properties and their values defined for this SpeechSynthesizer.
Returns:
getVoicesAsync
public Future
Get the available voices, asynchronously. Added in version 1.16.0
Returns:
getVoicesAsync
public Future
Get the available voices, asynchronously. Added in version 1.16.0
Parameters:
Returns:
setAuthorizationToken
public void setAuthorizationToken(String token)
Sets the authorization token used to communicate with the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the synthesizer will encounter errors while speech synthesis.
Parameters:
Applies to
Azure SDK for Java