SoundPlayer

Hello everyone, I'm trying to make my sounds play for future reference.
The code below is working, if you press "V", the bot will duplicate my speech.

 private void OnPlayerVoice(BasePlayer player, byte[] data)
 {
     Speak(data, player.transform.position);
 }
 private BasePlayer bot;
 private void Speak(byte[] data, Vector3 pos)
 {
     if(bot == null)
     {
         bot = GameManager.server.CreateEntity("assets/prefabs/player/player.prefab", pos) as BasePlayer;
         bot.Spawn();
     }

     Server.Broadcast($"speak: {data.Length}");

     NetWrite netWrite = Network.Net.sv.StartWrite();
     netWrite.PacketID(Message.Type.VoiceData);
     netWrite.EntityID(bot.net.ID);
     netWrite.BytesWithSize(data);

     netWrite.Send(new SendInfo(new List<Connection>() { BasePlayer.activePlayerList[0].Connection })
     {
         priority = Priority.Immediate
     });
 }

However, if I assume I will use any (short, because the rasta has a limit) .mp to base64, paste into the code and convert to byte[], and transfer to Speak(), then absolutely nothing will happen, no errors, nothing, the bot will not even open its mouth.

If someone has worked with this, can you tell me what's wrong? :/

        [ChatCommand("s")]
        private void SaveClip(BasePlayer p)
        {
            string path = "CandyEvent/Sounds/" + "sound.json";

            Interface.Oxide.DataFileSystem.WriteObject(path, volume);
        }

        [ChatCommand("d")]
        private void LoadClip(BasePlayer p)
        {
            string path = "CandyEvent/Sounds/" + "sound.json";

            List<byte[]> data = Interface.Oxide.DataFileSystem.ReadObject<List<byte[]>>(path);

            ServerMgr.Instance.StartCoroutine(PlaySoundCoroutine(data));
        }

        private IEnumerator PlaySoundCoroutine(List<byte[]> data)
        {
            foreach (var item in data)
            {
                Speak(item, BasePlayer.activePlayerList[0].transform.position);
                yield return new WaitForSeconds(0.1f);
            }
        }

        private List<byte[]> volume = new List<byte[]>();
        private void OnPlayerVoice(BasePlayer player, byte[] data)
        {
            volume.Add(data);

            Speak(data, player.transform.position);
        }

I've recorded and played back my voice, and everything is working well.
The only question left is how to record the audio track correctly.

Look at HumanNPC plugin Also voice bytes are not  mp3

q3pISn1wNmP3gBC.png Razor

Look at HumanNPC plugin Also voice bytes are not  mp3

I've already figured it out, delved into this topic, and realized that first you need to compress audio through OPUS, then pass it through the steam codec.

but I haven't figured out how to implement all this yet.

olol321

I've already figured it out, delved into this topic, and realized that first you need to compress audio through OPUS, then pass it through the steam codec.

but I haven't figured out how to implement all this yet.

Can you sare your findings in this topic so others can see.

X7qVjK80aHsR3zA.png Razor

Can you sare your findings in this topic so others can see.

https://github.com/LucienMP/Rust-Voice-Streaming-Plugin
- best repository for this theme

With sound at 128 bits per second, everything works more or less fine, but when using other bitrates, the sound is distorted. Unfortunately, my knowledge of C++ (if the problemis with him)  and understanding of the problem do not allow me to solve this problem on my own.

Ya that info has neen there for a while now and does work.