diff --git a/Assets/HoloToolkit/Utilities/Scripts/TextToSpeechManager.cs b/Assets/HoloToolkit/Utilities/Scripts/TextToSpeechManager.cs
index 71a47ac8bf8..616bfe7a26a 100644
--- a/Assets/HoloToolkit/Utilities/Scripts/TextToSpeechManager.cs
+++ b/Assets/HoloToolkit/Utilities/Scripts/TextToSpeechManager.cs
@@ -382,6 +382,33 @@ public void SpeakText(string text)
#endif
}
+ ///
+ /// Returns whether or not the AudioSource is actively playing.
+ ///
+ ///
+ /// True, if the AudioSource is playing. False, if the AudioSource is not playing or is null.
+ ///
+ public bool IsSpeaking()
+ {
+ if (audioSource != null)
+ {
+ return audioSource.isPlaying;
+ }
+
+ return false;
+ }
+
+ ///
+ /// Stops text-to-speech playback.
+ ///
+ public void StopSpeaking()
+ {
+ if (IsSpeaking())
+ {
+ audioSource.Stop();
+ }
+ }
+
///
/// Gets or sets the audio source where speech will be played.
///
diff --git a/Assets/HoloToolkit/Utilities/Tests/TextToSpeechManagerTest.cs b/Assets/HoloToolkit/Utilities/Tests/TextToSpeechManagerTest.cs
index 3f59a7bc5b9..313312a1961 100644
--- a/Assets/HoloToolkit/Utilities/Tests/TextToSpeechManagerTest.cs
+++ b/Assets/HoloToolkit/Utilities/Tests/TextToSpeechManagerTest.cs
@@ -36,7 +36,7 @@ private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tap
// If we have a text to speech manager on the target object, say something.
// This voice will appear to emanate from the object.
- if (tts != null)
+ if (tts != null && !tts.IsSpeaking())
{
// Get the name
var voiceName = Enum.GetName(typeof(TextToSpeechVoice), tts.Voice);
@@ -47,6 +47,10 @@ private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tap
// Speak message
tts.SpeakText(msg);
}
+ else if (tts.IsSpeaking())
+ {
+ tts.StopSpeaking();
+ }
}
}