C# Class HoloToolkit.Unity.TextToSpeechManager

Enables text to speech using the Windows 10 SpeechSynthesizer class.
SpeechSynthesizer generates speech as a SpeechSynthesisStream. This class converts that stream into a Unity AudioClip and plays the clip using the AudioSource you supply in the inspector. This allows you to position the voice as desired in 3D space. One recommended approach is to place the AudioSource on an empty GameObject that is a child of Main Camera and position it approximately 0.6 units above the camera. This orientation will sound similar to Cortana's speech in the OS.
Inheritance: UnityEngine.MonoBehaviour
显示文件 Open project: Microsoft/HoloToolkit-Unity Class Usage Examples

Public Methods

Method Description
SpeakSsml ( string ssml ) : void

Speaks the specified SSML markup using text-to-speech.

SpeakText ( string text ) : void

Speaks the specified text using text-to-speech.

Private Methods

Method Description
BytesToFloat ( byte firstByte, byte secondByte ) : float

Converts two bytes to one float in the range -1 to 1

BytesToInt ( byte bytes, int offset ) : int

Converts an array of bytes to an integer.

LogSpeech ( string text ) : void

Logs speech text that normally would have been played.

PlaySpeech ( string text, Func speakFunc ) : void

Executes a function that generates a speech stream and then converts and plays it in Unity.

Start ( ) : void
ToClip ( string name, float audioData, int sampleCount, int frequency ) : AudioClip

Dynamically creates an AudioClip that represents raw Unity audio data.

ToUnityAudio ( byte wavAudio, int &sampleCount, int &frequency ) : float[]

Converts raw WAV data into Unity formatted audio data.

Method Details

SpeakSsml() public method

Speaks the specified SSML markup using text-to-speech.
public SpeakSsml ( string ssml ) : void
ssml string /// The SSML markup to speak. ///
return void

SpeakText() public method

Speaks the specified text using text-to-speech.
public SpeakText ( string text ) : void
text string /// The text to speak. ///
return void