History

Some experimentation yields promising results...

Zach Fox committed 8 years ago

Commit 26e388b1 parent 79f30eb5 files · +769 −736Browse files

Showing the changes to interface/src/scripting (2 of 5 files). Show all

Unified · Split

2 files
  1. interface/src/scripting/TTSScriptingInterface.cpp +12 −5
  2. interface/src/scripting/TTSScriptingInterface.h +9 −2
interface/src/scripting/TTSScriptingInterface.cpp+12−5
@@ -65,7 +65,7 @@ void TTSScriptingInterface::testTone(const bool& alsoInject) { · 64 unmodified lines
6565 int16_t temp = (glm::sin(glm::radians((float)a))) * 32768;
6666 samples[a] = temp;
6767 }
68− emit ttsSampleCreated(_lastSoundByteArray);
68+ emit ttsSampleCreated(_lastSoundByteArray, AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * 50, 96);
6969
7070 if (alsoInject) {
7171 AudioInjectorOptions options;
@@ -75,11 +75,16 @@ void TTSScriptingInterface::testTone(const bool& alsoInject) { · 3 unmodified lines
7575 }
7676 }
7777
78−void TTSScriptingInterface::speakText(const QString& textToSpeak, const bool& alsoInject) {
78+void TTSScriptingInterface::speakText(const QString& textToSpeak,
79+ const int& newChunkSize,
80+ const int& timerInterval,
81+ const int& sampleRate,
82+ const int& bitsPerSample,
83+ const bool& alsoInject) {
7984 WAVEFORMATEX fmt;
8085 fmt.wFormatTag = WAVE_FORMAT_PCM;
81− fmt.nSamplesPerSec = 24000;
82− fmt.wBitsPerSample = 16;
86+ fmt.nSamplesPerSec = sampleRate;
87+ fmt.wBitsPerSample = bitsPerSample;
8388 fmt.nChannels = 1;
8489 fmt.nBlockAlign = fmt.nChannels * fmt.wBitsPerSample / 8;
8590 fmt.nAvgBytesPerSec = fmt.nSamplesPerSec * fmt.nBlockAlign;
@@ -146,7 +151,7 @@ void TTSScriptingInterface::speakText(const QString& textToSpeak, const bool& al · 60 unmodified lines
146151 _lastSoundByteArray.resize(0);
147152 _lastSoundByteArray.append(buf1, dwSize);
148153
149− emit ttsSampleCreated(_lastSoundByteArray);
154+ emit ttsSampleCreated(_lastSoundByteArray, newChunkSize, timerInterval);
150155
151156 if (alsoInject) {
152157 AudioInjectorOptions options;
@@ -160,4 +165,6 @@ void TTSScriptingInterface::stopLastSpeech() { · 7 unmodified lines
160165 if (_lastSoundAudioInjector) {
161166 _lastSoundAudioInjector->stop();
162167 }
168+
169+ emit clearTTSBuffer();
163170 }
interface/src/scripting/TTSScriptingInterface.h+9−2
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <sapi.h> // SAPI
2020 #include <sphelper.h> // SAPI Helper
2121 #include <AudioInjector.h>
22+#include <AudioConstants.h>
2223
2324 class TTSScriptingInterface : public QObject, public Dependency {
2425 Q_OBJECT
@@ -28,11 +29,17 @@ public: · 3 unmodified lines
2829 ~TTSScriptingInterface();
2930
3031 Q_INVOKABLE void testTone(const bool& alsoInject = false);
31− Q_INVOKABLE void speakText(const QString& textToSpeak, const bool& alsoInject = false);
32+ Q_INVOKABLE void speakText(const QString& textToSpeak,
33+ const int& newChunkSize = (AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * 50),
34+ const int& timerInterval = 96,
35+ const int& sampleRate = 24000,
36+ const int& bitsPerSample = 16,
37+ const bool& alsoInject = false);
3238 Q_INVOKABLE void stopLastSpeech();
3339
3440 signals:
35− void ttsSampleCreated(QByteArray outputArray);
41+ void ttsSampleCreated(QByteArray outputArray, const int& newChunkSize, const int& timerInterval);
42+ void clearTTSBuffer();
3643
3744 private:
3845 class CComAutoInit {