The sound recording function does not work for me in HumanNPC v0.6.8.

Hi,

the sound recording function does not work for me in HumanNPC v0.6.8.

I created a new recording using /npc_sound add kobani01, held the voice key and spoke, then used /npc_sound save. The recording is saved, but when the NPC is interacted with, the following error is always generated:

Failed to call hook 'OnEnterNPC' on plugin 'HumanNPC v0.6.8' (ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: startIndex)
at System.BitConverter.ToInt32 (System.Byte[] value, System.Int32 startIndex) [0x00010] in <41d29b352f6a475ab1bf7c6628b82790>:0
at Oxide.Plugins.HumanNPC.FromSaveData (System.Byte[] bytes) [0x0000e] in <1105daf5b94b4e59a2c5d374b8186923>:0
at Oxide.Plugins.HumanNPC+SoundFileConverter.ReadJson (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Object existingValue, Newtonsoft.Json.JsonSerializer serializer) [0x0001c] in <1105daf5b94b4e59a2c5d374b8186923>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable (Newtonsoft.Json.JsonConverter converter, Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Object existingValue) [0x00055] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x0004e] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00267] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0015c] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0006d] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000d9] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00053] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <271c58b7a8684db5a2c92be17a81f252>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <271c58b7a8684db5a2c92be17a81f252>:0
at Oxide.Core.Configuration.DynamicConfigFile.ReadObject[T] (System.String filename) [0x00028] in <15f61ddda771464d8246ebdce8ff4811>:0
at Oxide.Core.DataFileSystem.ReadObject[T] (System.String name) [0x00018] in <15f61ddda771464d8246ebdce8ff4811>:0
at Oxide.Plugins.HumanNPC.LoadDataSound (System.String name) [0x0002d] in <1105daf5b94b4e59a2c5d374b8186923>:0
at Oxide.Plugins.HumanNPC.OnEnterNPC (BasePlayer npc, BasePlayer player) [0x0015d] in <1105daf5b94b4e59a2c5d374b8186923>:0
at Oxide.Plugins.HumanNPC.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x003d6] in <1105daf5b94b4e59a2c5d374b8186923>:0
at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <42f9bedc659b4f4786eb778d3cd58968>:0
at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000de] in <15f61ddda771464d8246ebdce8ff4811>:0
at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <15f61ddda771464d8246ebdce8ff4811>:0


It happens every time when the NPC tries to play the recorded sound.

I also tested with a freshly recorded sound, so it does not seem to be an old/corrupted recording.

Could you please check the sound recording/saving system? It appears that the saved voice data is either empty or cannot be read correctly by FromSaveData().

HumanNPC version: 0.6.8

Look at the data file it created. does it have entrys?

One more detail regarding the saved files:

The files are not exactly identical, but they are extremely small.

For example, I get:

{
  "Data": "H4sIAGxPvGoA/w=="
}

and another recording gives:

{
  "Data": "H4sIAI9QvGoA/w=="
}

The first recording was very short, while the second one was significantly longer. However, both files are still only a few bytes of actual encoded data.

I am definitely holding the voice key and speaking during the recording.

So even with a much longer recording, the saved data remains extremely small and the NPC still produces the BitConverter.ToInt32 / FromSaveData error when trying to load it.

Could you please check whether the voice packets are being captured correctly by OnPlayerVoice() and whether the data is being serialized correctly by SoundFileConverter?

Test your mic make sure its working ingame. make sure your holding down your ingame mic key the hole time talking.

I understand what you mean, but I have already tested my microphone extensively.

The microphone works perfectly in-game. Other players can hear and understand me clearly, and for example the Halloween plugin works without any problems with my microphone. So I don't think the microphone or my push-to-talk key is the issue here.

I’m not stupid πŸ˜„ β€” if the exact same microphone works correctly with other plugins, I suspect there may be something specific in your plugin that is preventing the voice input from being detected correctly.

Would you give me permission to make a small modification to your plugin for testing? I have an idea for something I could change that might solve the problem.

If my modification works, I will of course send you the exact changes I made, so you can check them and potentially integrate the fix into your plugin.

I would only do this for testing and would not redistribute or publish your modified code without your permission.

n6gwsnIAqzWZKFR.png Kobani

I understand what you mean, but I have already tested my microphone extensively.

The microphone works perfectly in-game. Other players can hear and understand me clearly, and for example the Halloween plugin works without any problems with my microphone. So I don't think the microphone or my push-to-talk key is the issue here.

I’m not stupid πŸ˜„ β€” if the exact same microphone works correctly with other plugins, I suspect there may be something specific in your plugin that is preventing the voice input from being detected correctly.

Would you give me permission to make a small modification to your plugin for testing? I have an idea for something I could change that might solve the problem.

If my modification works, I will of course send you the exact changes I made, so you can check them and potentially integrate the fix into your plugin.

I would only do this for testing and would not redistribute or publish your modified code without your permission.

Thaks for debuging that for me but no one called you STUPED... But i can if you like 🀑...
Issue should be resolved.

uSdatgtQypV11y4.png Razor

Thaks for debuging that for me but no one called you STUPED... But i can if you like 🀑...
Issue should be resolved.

Great, thanksβ€”it's working now.πŸ‘