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 "SpeechScriptingInterface.h"
#include "avatar/AvatarManager.h" #include "avatar/AvatarManager.h"
#include <AudioInjector.h>
SpeechScriptingInterface::SpeechScriptingInterface() { SpeechScriptingInterface::SpeechScriptingInterface() {
// //
@ -94,7 +93,7 @@ void SpeechScriptingInterface::speakText(const QString& textToSpeak) {
ULONG streamNumber; ULONG streamNumber;
hr = m_tts->Speak(reinterpret_cast<LPCWSTR>(textToSpeak.utf16()), 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); &streamNumber);
if (FAILED(hr)) { if (FAILED(hr)) {
qDebug() << "Speak failed."; qDebug() << "Speak failed.";
@ -130,5 +129,9 @@ void SpeechScriptingInterface::speakText(const QString& textToSpeak) {
AudioInjectorOptions options; AudioInjectorOptions options;
options.position = DependencyManager::get<AvatarManager>()->getMyAvatarPosition(); 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 #endif
#include <sapi.h> // SAPI #include <sapi.h> // SAPI
#include <sphelper.h> // SAPI Helper #include <sphelper.h> // SAPI Helper
#include <AudioInjector.h>
class SpeechScriptingInterface : public QObject, public Dependency { class SpeechScriptingInterface : public QObject, public Dependency {
Q_OBJECT Q_OBJECT
@ -27,9 +28,9 @@ public:
~SpeechScriptingInterface(); ~SpeechScriptingInterface();
Q_INVOKABLE void speakText(const QString& textToSpeak); Q_INVOKABLE void speakText(const QString& textToSpeak);
Q_INVOKABLE void stopLastSpeech();
private: private:
class CComAutoInit { class CComAutoInit {
public: public:
// Initializes COM using CoInitialize. // Initializes COM using CoInitialize.
@ -70,6 +71,8 @@ private:
// Default voice token // Default voice token
CComPtr<ISpObjectToken> m_voiceToken; CComPtr<ISpObjectToken> m_voiceToken;
AudioInjectorPointer lastSound;
}; };
#endif // hifi_SpeechScriptingInterface_h #endif // hifi_SpeechScriptingInterface_h