8000 Prevent processing of muted user's speech after unmuting on WebGL · uezo/ChatdollKit@50700b6 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 50700b6

Browse files
committed
Prevent processing of muted user's speech after unmuting on WebGL
- Fixed a bug where speech data from a muted user could be processed after unmuting in WebGL builds. - Now, when the user is muted or the microphone is not recording, the buffer is cleared and no old audio data is processed after unmuting. - This prevents unintended speech recognition or processing of buffered audio that was captured during mute state.
1 parent 299b3f0 commit 50700b6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Scripts/SpeechListener/MicrophoneManager.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,15 @@ private void UpdateLinearVolumes()
131131
#if UNITY_WEBGL && !UNITY_EDITOR
132132
private float[] GetAmplitudeData()
133133
{
134+
var buffer = webGLSamplesBuffer.Count > 0 ? webGLSamplesBuffer.Dequeue() : new float[0];
135+
134136
if (IsMuted || IsWebGLMicrophoneRecording() == 0)
135137
{
136138
return new float[0];
137139
}
138-
139-
if (webGLSamplesBuffer.Count > 0)
140-
{
141-
return webGLSamplesBuffer.Dequeue();
142-
}
143140
else
144141
{
145-
return new float[0];
142+
return buffer;
146143
}
147144
}
148145

0 commit comments

Comments
 (0)
0