Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Voice chat for unity networking?

Discussion in 'Multiplayer' started by PhilSA, Apr 26, 2016.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I'm looking for a voice chat solution compatible with Unity's new networking system, but haven't found anything functionnal/trustworthy yet. All I could find were very badly-reviewed asset store packages that haven't been updated in over a year, and a project on github that throws errors as soon as it detects a mic. Can anyone point me to something?

    Also, is Unity planning on adding this as an official feature at some point? Seems like there is a very clear need for a solid solution in that department
     
    Opeth001, TwoTen, MrLucid72 and 2 others like this.
  2. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Im also very interested in this : )
     
  3. Deleted User

    Deleted User

    Guest

    zhangjin_ likes this.
  4. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    First one is not Unet, he other one looks interesting though.
     
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
  6. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Would be awesome if you could share your findings here : )
     
  7. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Allright so if you want to follow along;
    - Download the VoiceChat project
    - Open it in Unity
    - Open the "Networking [HLAPI]" scene
    - Press Play
    - Select "LAN Host(H)"
    - Select your mic
    - Notice the error in the console

    Now what I've been able to find out so far is that it seems like this "Network Id not set" error only happens when the host of the game tries to select a device (so presumably, it happens if the server tries to use voice recording). I was able to make things work by following these steps:
    - Make a build with the "Networking [HLAPI]" scene
    - Start one instance as host, but don't select a mic. Just leave it there
    - Start two client instances, and select your mics
    - Try to record on one of those client instances (hold 'P' to record), and you'll hear your voice on the other one

    Basically all that's left to figure out for me is why this VoiceChat system doesn't correctly assign a net ID to the host
     
  8. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Strange, so it works from client to the others, but not from the host. I wonder how the bandwidth is for this solution as well, would be nice if it was not super heavy.
    Thank for looking into this : )
     
  9. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    I had the same error, so I went through these steps but was not able to get the two instances of the build to transmit voice. I was able to hear myself when I check the local Debug mode, but cannot do it over the network at all. Has anyone gotten further on this issue? thanks in advance.
     
  10. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    Did you try looking for existing solutions like TeamSpeak ?? Far as I can remember they had Unity integration package.
     
  11. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    85
  12. flammen_schwert

    flammen_schwert

    Joined:
    Feb 18, 2015
    Posts:
    2
    I'm trying to get the voice chat to work with the asset from fholm.
    Did you have any progress with the networkid of the host?
     
  13. Deleted User

    Deleted User

    Guest

    I'm using DFvoice and UNET, and managed finally to work.
     
    Last edited by a moderator: Nov 30, 2016
  14. Pulas

    Pulas

    Joined:
    Feb 26, 2014
    Posts:
    10
    I encountered the same problem: "NetworkId not set". How to solve it?
     
  15. RaymondYan

    RaymondYan

    Joined:
    Dec 6, 2016
    Posts:
    1
    In case anyone is still facing the "NetworkId not set" problem for the VoiceChat, here is the solution:
    • Mark the following code in VoiceChat\Assets\VoiceChat\Scripts\VoiceChatRecorder.cs
    Code (CSharp):
    1.         public bool StartRecording()
    2.         {
    3.             /*
    4.             if (NetworkId == 0 && !VoiceChatSettings.Instance.LocalDebug)
    5.             {
    6.                 Debug.LogError("NetworkId is not set");
    7.                 return false;
    8.             }*/
    • And Then modified the code in VoiceChat\Assets\VoiceChat\Scripts\Networking\VoiceChatNetworkProxy.cs
    From:
    Code (CSharp):
    1. public bool isMine { get { return networkId != 0 && networkId == localProxyId; } }
    To:
    Code (CSharp):
    1. public bool isMine { get { return networkId == localProxyId; } }
    • In VoiceChatPlayer.cs, modified from:
    Code (CSharp):
    1.  
    2. public void OnNewSample(VoiceChatPacket newPacket)
    3.         {
    4.             // Set last time we got something
    5.             lastRecvTime = Time.time;
    6.  
    7.             packetsToPlay.Add(newPacket.PacketId, newPacket);
    8.  
    9.             if (packetsToPlay.Count < 10)
    10.             {
    11.                 return;
    12.             }
    13.  
    To:
    Code (CSharp):
    1.         public void OnNewSample(VoiceChatPacket newPacket)
    2.         {
    3.             // Set last time we got something
    4.             lastRecvTime = Time.time;
    5.             // Add this new line;
    6.             if ( packetsToPlay.ContainsKey( newPacket.PacketId ) ) return;
    7.  
    8.             packetsToPlay.Add(newPacket.PacketId, newPacket);
    9.  
    10.             if (packetsToPlay.Count < 10)
    11.             {
    12.                 return;
    13.             }
    I think the purpose of the author is to check if we have connect to the network, if not the networkId would be 0. However in Unity the server side client's network connection id is also 0.
     
    Last edited: Dec 6, 2016
  16. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    yes we will add voip support. But I do not have any ETA for this.. Sorry about
     
    Cippman, TwoTen, LostPanda and 8 others like this.
  17. Pulas

    Pulas

    Joined:
    Feb 26, 2014
    Posts:
    10
    Wow. Big thanks for your help.
     
    sun_stealer and MendyBerger like this.
  18. flammen_schwert

    flammen_schwert

    Joined:
    Feb 18, 2015
    Posts:
    2
    Thank you!
    I've not worked on my project for the last few weeks... I figured out your remarks on the code back than except for the ones in the VoiceChatPlayer.
     
  19. Traxxy

    Traxxy

    Joined:
    Mar 21, 2016
    Posts:
    18
  20. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
  21. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    86
    thank you :)
     
  22. kitten_of_death

    kitten_of_death

    Joined:
    Feb 27, 2015
    Posts:
    4
    I can hear the voice as a client, but why the networkId is 0 ?? Did anyone get it fully working with client-server both ways?
     
  23. zhangjin_

    zhangjin_

    Joined:
    Aug 6, 2015
    Posts:
    1
    It can work by running one instance as a host and another instance as client, I think what RaymondYan says here
    means that the client which runs as a host will have its networkId as 0 because according to UNET doc here, the host side is basically a client that works also as a server. Please correct me if I am wrong here.
     
  24. pavan123

    pavan123

    Joined:
    Nov 5, 2016
    Posts:
    4
    Hi I have tried the second link https://github.com/fholm/unityassets/tree/master/VoiceChat provided by TiToMoskito. i have downloaded that zip file and opened voice chat project in my unity application and did the required modifications,now it is working fine for me,able to get voice chat between server and client through microphone but one problem annoys me a lot that is connection between server and client through microphone is no longer available means connection keeps break down in less than a minute.could anyone help me to figure out this problem.
     
    Last edited: Jan 28, 2017
  25. vicator

    vicator

    Joined:
    Oct 12, 2014
    Posts:
    30
    Testing the VoiceChat by fholm. I am experiencing a delay over time causing the playback of the actual recorded chat to lag behind more and more in time of clients.

    Anyone got any hints of where to start looking to solve this? Is it a case of discarding packets on the listening clients if their timestamp in relation to the server is way off?
     
  26. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    91
    I realize that PhilSA probably isn't interested anymore after all this time, but since other people might be...

    We are using UNET and tried every package we could find. The only ones that worked with low latency and good voice quality were:
    • TeamSpeak 3 SDK
      • Pros: Low latency. Good voice quality. Makes its own connection (doesn't use UNET), but doesn't need a big network solution besides UNET. Super easy to setup and use.
      • Cons: Doesn't use AudioSources to play back voice audio, which makes using plugins for spatialization (e.g. for VR) impossible. Minor bugs and pretty much non-existing support. Needs an additional TeamSpeak server.
    • Photon Voice
      • Pros: Low latency. Good voice quality. Uses AudioSources to play back voice audio.
      • Cons: Needs an additional Photon connection (and server) on top of our UNET connection. Is a bit harder to set up than TeamSpeak.
     
    VrischDev and chgeorgiadis like this.
  27. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    55
    sun_stealer likes this.
  28. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    I've recently released Dissonance Voice Chat on the asset store. Dissonance is designed to work with any networking system (out of the box it works with Unet, Photon and Forge - you'll need to write a little bit of glue code if you're using another network system).
     
    digiross, ilmario and TwoTen like this.
  29. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    97
    YEEEEEEEEEEEEEEESSSSS!!! I have been waiting forever for something like Dissonance to come out! Glad to see it finally released and that so far it's getting great reviews. Instant buy for me!

    Also, OP the answer to your question is most likely buy Dissonance, it's really the only asset on the market that does VOIP besides Photon Voice which locks you into paying Photon per concurrent user (yuck).
     
    Nyarlathothep likes this.
  30. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    91
    Does Dissonance use AudioSources to play back the audio?

    edit: Disregard that, I found the video which shows that it does. Awesome - I'll probably have a go with it if my client agrees!

    (By the way, you might want to add the video to the asset description and/or the example thumbnail section.)
     
    Last edited: Mar 8, 2017
  31. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Good idea, I'll have a look at doing that with the next release (planned for early next week).

    Just to sum up a few of the things Dissonance does:

    - Playback through AudioSource. This means various mixer effects should work in the same way as any other audio source in your games. We've got several people successfully using the Oculus Spatializer with Dissonance for example.
    - Opus codec with Speex preprocessing. Everyone uses Opus for encoding, it's a fantastic codec. In Dissonance we're also running the voice through the speex preprocessor to further improve the audio quality (noise removal, automatic gain control).
    - As much work as possible is done off the main thread in Dissonance which means we're not limited by a low framerate introducing extra latency into the speech. It also means that Dissonance should never impact your frame rate.
    - There's a low level channels API which allows you to explicitly control who is talking and who's listening. There's a load of possibilities for setting up complex channel hierarchies (e.g. raid members can listen but get muted as soon as the raid leader talks).
     
  32. Deleted User

    Deleted User

    Guest

    Hi there, does Dissonance supports Unet HLAPI? Thanks
     
    Nyarlathothep and TwoTen like this.
  33. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Last edited: Aug 30, 2017
    Deleted User likes this.
  34. Deleted User

    Deleted User

    Guest

    Thank you so much. ;)
     
    Nyarlathothep likes this.
  35. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Has anyone had any success with the Steamworks Voicechat?
    I'm concidering giving it a try.
     
  36. MendyBerger

    MendyBerger

    Joined:
    Sep 17, 2017
    Posts:
    2
    Last edited: Oct 17, 2017
    Deleted User likes this.
  37. MendyBerger

    MendyBerger

    Joined:
    Sep 17, 2017
    Posts:
    2

    I also really appreciate it!
     
  38. chgeorgiadis

    chgeorgiadis

    Joined:
    Jan 30, 2018
    Posts:
    51

    @TobiasW i would like to use voice chat in a multiplayer VR game. Do you have any update in these suggestions? Thank you!
     
  39. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    91
    Hey @chgeorgiadis! Sorry, it's been forever since I worked on that. We also tried Dissonance, but I don't remember which one we picked at the end.
     
    chgeorgiadis and Nyarlathothep like this.
  40. tushar1985

    tushar1985

    Joined:
    May 7, 2013
    Posts:
    5
    Hi,

    I tried using your repo it works fine, but i am getting the issue of Echo.
    Any help or suggestion you can provide?

    Thanks in advance.
     
  41. nchung123

    nchung123

    Joined:
    Jul 9, 2019
    Posts:
    1
    Hi,
    Does Dissonance work with native development or just Unity?
     
  42. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    What exactly do you mean by native?

    If you mean applications built without Unity then Dissonance isn't designed for that but I guess it could be adapted for it. Ultimately we only use Unity for audio input and output.

    The input can be easily replaced (https://dissonance.readthedocs.io/en/latest/Tutorials/Custom-Microphone-Capture/index.html) with a custom microphone capture object. You could tie that into whatever audio recording system you want.

    Audio playback is not designed to be easily replaceable, but it's contained within a pair of behaviours (one to manage the AudioSource, one to play the audio) so you could probably replace that without too much trouble.
     
  43. KnightRiderGuy

    KnightRiderGuy

    Joined:
    Nov 23, 2014
    Posts:
    515
    Sorry for reviving and old post but I found this an interesting read.
    I'm looking into doing some voice and possible video chat stuff for my Knight Rider Car project.
    I've had some success using Pun Chat the free version in the Unity Asset store to fairly effectively make a sort of car phone that can communicate between the application running on KITT's computer in the car and a "Home base" app running on a PC in the house. It seems to work well as for my project I do not need any of the 3D elements associated with the Pun Chat example project "Push To Talk" demo, that and communication is to be pretty limited to just conversation between the App in the car, KITT's onboard A.I. and the home base app.
    I'm pretty new to the whole networking with Unity but had stumbled upon Pun Chat, I'm not sure if it's the best for my type of scenario?? There may be better suited options given my limited requirements??

    Also about the video chat possibilities. I've always thought it would be a cool idea to include some sort of "Video Phone" type of capability with my app in the car, again for the expressed purposes of communicating with a "Home Base" app.

    Also working on an Android Smart Watch app to do something similar to what Michael's watch in the TV show did which was to act as a "Com-Link" between him and KITT. I did test the Pun Chat out on my Android Samsung Galaxy Note II and it seemed to work well, but again being new to the whole networking options on Unity I'm not 100% on if it's the best way to go?? I like the idea of the smart watch because I think it can use heart rate information and maybe??? Maybe I can send that information also to KITT for..... well more reasons than I could list here. ;)

    Any thoughts or ideas on which methods or options I should explore would be greatly appreciated.
     
  44. librelifen

    librelifen

    Joined:
    Apr 23, 2020
    Posts:
    7
    From what I understand, it's a great option for smart homes. As a big fan of this technology, I was wondering if you had achieved anything?