Acoustic feedback for successful speech recognition
Hi everyone!
When starting to develop my app, I used the Academy tutorial as a reference for my speech recognition manager. It's been a while and if I remember correctly, the KeywordManager script wasn't available then. So I hard-coded my voice commands into my script.
Now I'd like to use the KeywordManager because I prefer the flexibility of defining the commands and their reactions in the Unity Editor. But as far as I can figure it, it is not possible to play a sound when a voice command is recognized correctly as it is right now. Since I'd like to have some kind of acoustic feedback after a recognition, I've got three ideas for enhancing the KeywordManager with this functionality:
- Adding an AudioSource and a public AudioClip to the class which is played when the registered action is called
or
- adding a new event handler and a new event to the class (e.g. OnKeywordRecognized) which allows us to subscribe to this event and play a sound in another class (e.g. SoundManager)
or
- making the created KeywordRecognizer a public accessible property ( get; private set; ). This would enable us to also subscribe to the KeywordRecognizer's OnPhraseRecognized event.
I'd like to hear about your thoughts!
// edit: I've just discovered that the SpeechInputSource now has the same functionality. I'm using the latest release of the HTK, so when I looked into it, I just could assign keyboard shortcuts. So just see this issue as an improvement to the SpeechInputSource instead of the KeywordManager.
I created a pull request https://github.com/Microsoft/HoloToolkit-Unity/pull/581 for 2. It adds a UnityEvent that triggers on any recognized phrase or keycode.
Oh, thanks for already implementing this feature!
I would have done this by myself, I just wanted to discuss the approach before. However, using a UnityEvent is a even nicer solution.
But I think you committed too much lines of code in the KeywordManager.unity scene. ;-)
Was I able to address this in PR https://github.com/Microsoft/HoloToolkit-Unity/pull/533?
Also the KeywordManager is going to be marked as obsolete due to the SpeechInputSource pretty much doing the same thing.
I have to admit that I didn't understand your changes as a whole yet.
But I reckon that I'm able to implement the ISpeechHandler interface then and play a audio clip in the OnSpeechKeywordRecognized method?
correct.
Thank you!