File tree 2 files changed +7
-3
lines changed
2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public ExampleBot() {
32
32
33
33
// Windows (with closed captioning instead of wake detection)
34
34
cord = VocalCord .newConfig (this ).withClosedCaptioning ().withTTS (SsmlVoiceGender .MALE ,
35
- true ).build ();
35
+ false ).build ();
36
36
37
37
// Linux (using WSL)
38
38
// cord = VocalCord.newConfig(this).withWakeDetection("/mnt/c/Users/wdavi/IdeaProjects/VocalCord/native/linux/libjni_porcupine.so",
Original file line number Diff line number Diff line change @@ -48,8 +48,10 @@ byte[] tts(String text) throws Exception {
48
48
byte [] pcm = audioContents .toByteArray ();
49
49
50
50
// Three things need to happen - big endian, stereo, pad to a multiple of 3840
51
- byte [] converted = new byte [pcm .length * 2 + (AUDIO_FRAME - pcm .length * 2 % AUDIO_FRAME )]; // ensures converted is a multiple of AUDIO_FRAME
52
- for (int i = 0 ; i < pcm .length ; i += 2 ) {
51
+ // Add a frame of silence at the beginning so that the sound doesn't clip weirdly
52
+ byte [] converted = new byte [AUDIO_FRAME + pcm .length * 2 + (AUDIO_FRAME - pcm .length * 2 % AUDIO_FRAME )];
53
+ // ensures converted is a multiple of AUDIO_FRAME
54
+ for (int i = AUDIO_FRAME ; i < pcm .length ; i += 2 ) {
53
55
short reversed = Short .reverseBytes ((short ) ((pcm [i ] << 8 ) | (pcm [i + 1 ] & 0xFF )));
54
56
byte low = (byte ) (reversed >> 8 );
55
57
byte high = (byte ) (reversed & 0x00FF );
@@ -66,6 +68,8 @@ byte[] tts(String text) throws Exception {
66
68
}
67
69
68
70
void say (String phrase ) throws Exception {
71
+ this .index = Integer .MAX_VALUE ;
72
+
69
73
if (ttsCache != null ) {
70
74
TTSCache .CacheResponse response = ttsCache .checkCache (phrase );
71
75
You can’t perform that action at this time.
0 commit comments