I love it.

This commit is contained in:
Zach Fox 2018-10-10 17:36:38 -07:00
parent d8c9712dd2
commit 5d4de3d3b0
2 changed files with 10 additions and 4 deletions

View file

@ -11,7 +11,6 @@
#include "SpeechScriptingInterface.h"
#include "avatar/AvatarManager.h"
#include <AudioInjector.h>
SpeechScriptingInterface::SpeechScriptingInterface() {
//
@ -94,7 +93,7 @@ void SpeechScriptingInterface::speakText(const QString& textToSpeak) {
ULONG streamNumber;
hr = m_tts->Speak(reinterpret_cast<LPCWSTR>(textToSpeak.utf16()),
SPF_IS_NOT_XML | SPF_ASYNC | SPF_PURGEBEFORESPEAK,
SPF_IS_XML | SPF_ASYNC | SPF_PURGEBEFORESPEAK,
&streamNumber);
if (FAILED(hr)) {
qDebug() << "Speak failed.";
@ -130,5 +129,9 @@ void SpeechScriptingInterface::speakText(const QString& textToSpeak) {
AudioInjectorOptions options;
options.position = DependencyManager::get<AvatarManager>()->getMyAvatarPosition();
AudioInjector::playSound(byteArray, options);
lastSound = AudioInjector::playSound(byteArray, options);
}
void SpeechScriptingInterface::stopLastSpeech() {
lastSound->stop();
}

View file

@ -18,6 +18,7 @@
#endif
#include <sapi.h> // SAPI
#include <sphelper.h> // SAPI Helper
#include <AudioInjector.h>
class SpeechScriptingInterface : public QObject, public Dependency {
Q_OBJECT
@ -27,9 +28,9 @@ public:
~SpeechScriptingInterface();
Q_INVOKABLE void speakText(const QString& textToSpeak);
Q_INVOKABLE void stopLastSpeech();
private:
class CComAutoInit {
public:
// Initializes COM using CoInitialize.
@ -70,6 +71,8 @@ private:
// Default voice token
CComPtr<ISpObjectToken> m_voiceToken;
AudioInjectorPointer lastSound;
};
#endif // hifi_SpeechScriptingInterface_h