Skip to content

Commit 11b3ca7

Browse files
committed
Merge branch 'dev' into main
2 parents 1e8efe3 + 73243bf commit 11b3ca7

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

VRCOSC.Desktop/VRCOSC.Desktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<ApplicationIcon>game.ico</ApplicationIcon>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Version>0.0.0</Version>
9-
<FileVersion>2023.428.0</FileVersion>
9+
<FileVersion>2023.429.0</FileVersion>
1010
<Title>VRCOSC</Title>
1111
<Authors>VolcanicArts</Authors>
1212
<Company>VolcanicArts</Company>
1313
<Nullable>enable</Nullable>
14-
<AssemblyVersion>2023.428.0</AssemblyVersion>
14+
<AssemblyVersion>2023.429.0</AssemblyVersion>
1515
</PropertyGroup>
1616
<ItemGroup Label="Project References">
1717
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />

VRCOSC.Game/ChatBox/ChatBoxManager.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public bool SendEnabled
6565
private DateTimeOffset nextValidTime;
6666
private bool isClear;
6767
private bool isLoaded;
68-
private string lastText = string.Empty;
6968

7069
public void Load(Storage storage, GameManager gameManager, NotificationContainer notification)
7170
{
@@ -194,7 +193,6 @@ public void Initialise(VRChatOscClient oscClient, Bindable<int> sendDelay, Dicti
194193
nextValidTime = startTime;
195194
isClear = true;
196195
ModuleEnabledCache = moduleEnabledCache;
197-
lastText = string.Empty;
198196

199197
Clips.ForEach(clip => clip.Initialise());
200198
}
@@ -282,9 +280,6 @@ private void handleClip(Clip? clip)
282280

283281
private void sendText(string text)
284282
{
285-
if (text == lastText) return;
286-
287-
lastText = text;
288283
oscClient.SendValues(VRChatOscConstants.ADDRESS_CHATBOX_INPUT, new List<object> { text, true, false });
289284
}
290285

VRCOSC.Game/OSC/VRChat/VRChatOscClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class VRChatOscClient : OscClient
1212
{
1313
public Action<VRChatOscData>? OnParameterSent;
1414
public Action<VRChatOscData>? OnParameterReceived;
15+
private readonly Dictionary<string, List<object>> valuesCache = new();
1516

1617
public VRChatOscClient()
1718
{
@@ -32,6 +33,16 @@ public VRChatOscClient()
3233
private void sendData(OscData data)
3334
{
3435
data.PreValidate();
36+
37+
if (data.Address.StartsWith(VRChatOscConstants.ADDRESS_AVATAR_PARAMETERS_PREFIX))
38+
{
39+
if (valuesCache.TryGetValue(data.Address, out var previousValue))
40+
{
41+
if (data.Values.SequenceEqual(previousValue)) return;
42+
}
43+
}
44+
45+
valuesCache[data.Address] = data.Values;
3546
SendByteData(data.Encode());
3647
OnParameterSent?.Invoke(new VRChatOscData(data));
3748
}

VRCOSC.Modules/SpeechToText/SpeechToTextModule.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public class SpeechToTextModule : ChatBoxModule
2020
private readonly SpeechRecognitionEngine speechRecognitionEngine = new();
2121
private VoskRecognizer? recogniser;
2222
private bool readyToAccept;
23-
private bool shouldAnalyse => readyToAccept && (!GetSetting<bool>(SpeechToTextSetting.FollowMute) || Player.IsMuted.GetValueOrDefault());
23+
private bool listening;
24+
private bool shouldAnalyse => readyToAccept && listening && (!GetSetting<bool>(SpeechToTextSetting.FollowMute) || Player.IsMuted.GetValueOrDefault());
2425
private readonly object processingLock = new();
2526
private byte[]? buffer;
2627

@@ -40,6 +41,7 @@ protected override void CreateAttributes()
4041
CreateSetting(SpeechToTextSetting.FollowMute, "Follow Mute", "Only run recognition when you're muted", false);
4142

4243
CreateParameter<bool>(SpeechToTextParameter.Reset, ParameterMode.Read, "VRCOSC/SpeechToText/Reset", "Reset", "Manually reset the state to idle to remove the generated text from the ChatBox");
44+
CreateParameter<bool>(SpeechToTextParameter.Listen, ParameterMode.ReadWrite, "VRCOSC/SpeechToText/Listen", "Listen", "Whether Speech To Text is currently listening");
4345

4446
CreateVariable(SpeechToTextVariable.Text, "Text", "text");
4547

@@ -63,6 +65,7 @@ protected override void OnModuleStart()
6365

6466
Log("Model loading...");
6567
readyToAccept = false;
68+
listening = true;
6669

6770
Task.Run(() =>
6871
{
@@ -82,6 +85,7 @@ protected override void OnModuleStart()
8285
SetChatBoxTyping(false);
8386
SetVariableValue(SpeechToTextVariable.Text, string.Empty);
8487
ChangeStateTo(SpeechToTextState.Idle);
88+
SendParameter(SpeechToTextParameter.Listen, listening);
8589
}
8690

8791
protected override void OnModuleStop()
@@ -107,6 +111,10 @@ protected override void OnBoolParameterReceived(Enum key, bool value)
107111
ChangeStateTo(SpeechToTextState.Idle);
108112
SetVariableValue(SpeechToTextVariable.Text, string.Empty);
109113
break;
114+
115+
case SpeechToTextParameter.Listen:
116+
listening = value;
117+
break;
110118
}
111119
}
112120

@@ -186,7 +194,8 @@ private enum SpeechToTextSetting
186194

187195
private enum SpeechToTextParameter
188196
{
189-
Reset
197+
Reset,
198+
Listen
190199
}
191200

192201
private enum SpeechToTextState

0 commit comments

Comments
 (0)