• Stars
    star
    348
  • Rank 121,256 (Top 3 %)
  • Language
    C#
  • License
    MIT License
  • Created over 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Voice chat/VoIP solution for unity.

UniVoice

An extensible voice chat/VoIP solution for Unity.

Features

  • 👥 Group Voice Chat

    • Multiple peers can join a chatroom and exchange audio.
    • APIs to mute audio on a per peer basis
  • 📦 Plug-And-Play

    • No need to write audio and networking code for most use cases
    • Support for multiple network types, including PUN2 and WLAN
  • 🎛️ Customizable

    • UniVoice is pretty much collection of interfaces, you can make your own implementations
    • For more info, see the Customization section below

Installation

The recommended installation is via the UniVoice UPM package named com.adrenak.univoice available on npmjs.org

  1. Add the NPM registry with UniVoice as a scope. To do this, go to Edit/Project Settings/Package Manager, add the NPM scope registry with the URL https://registry.npmjs.org and add com.adrenak.univoice as a scope.

  2. Install the package from NPM registry To do this, go to Window/Package Manager and refresh packages. Select in the My Registries view (located at the top left, the default selection is Unity Registry), locate UniVoice and click install. After installation, the package will show up in the In Project view as well.

Usage

Creating a chatroom agent

To be able to host and join voice chatrooms, you need a ChatroomAgent instance.

var agent = new ChatroomAgent(IChatroomNetwork network, IAudioInput audioInput, IAudioOutputFactory audioOutputFactory);

Hosting and joining chatrooms

agent.Network is the most commonly accessed object to do things with UniVoice.

// Host a chatroom 
agent.Network.HostChatroom(optional_data);

// Join an existing
agent.Network.JoinChatroom(optional_data);

// Leave the chatroom
agent.Network.LeaveChatroom(optional_data);

// Closes a chatroom
agent.Network.CloseChatroom(optional_data);

The current mode of the ChatroomAgent can be accessed using agent.Network.CurrentMode, this will return a ChatroomAgentMode enum object, the possible values are:

  • Unconnected: The agent is neither hosting or currently a guest of a chatroom
  • Host: The agent is currently hosting a chatroom
  • Guest: The agent is currently a guest in a chatroom

Interacting with peers

Everyone in the chatroom is assigned an ID by the host. And everyone has a list of IDs of their peers. An ID in UniVoice is a C# short that is unique for each member in the chatroom

To get your ID

short myID = agent.Network.OwnID;

To get a list of the other peers in the chatroom, use this:

short others = agent.Network.PeerIDs

To mute everyone in the chatroom, use agent.MuteOthers = true;, set it to false to unmute. This will stop audio from every peer in the chatroom.

To mute yourself to everyone in the chatroom use agent.MuteSelf = true; set it to false to unmute. This will stop sending your audio to the peers in the chatroom.

For muting a specific peer, first get the peers settings object using this:

agent.PeerSettings[id].muteThem = true; // where id belongs to the peer you want to mute

If you want to mute yourself towards a specific peer, use this:

agent.PeerSettings[id].muteSelf = true; // where id belongs to the peer you don't want to hear you

Events

agent.Network provides several network related events. Refer to the API reference for them.

⚙️ Customization

UniVoice is a plug-and-play solution with several pre-existing modules. The most common use case (which is probably 3D/spatial audio group chat) doesn't need you to write any audio or networking code yourself

But it also offers you ways to extend and modify it.

🎤 Audio Input

UniVoice is audio input source agnostic. This means, it doesn't care where it is getting the audio from. It only cares about getting the audio data, giving you freedom to change where it gets that from.

  • transmit real-time mic input
  • send audio by reading an mp3 file from disk
  • send the audio track of a video file.
  • send in-game audio

The most common input source is real-time mic input. If this is what you're looking for, an official input implementation based on UniMic is available here which can be used for this.

The IAudioInput interface API reference is here

🔊 Audio Output

UniVoice is also audio output agnostic. This means, it doesn't care what you do with the audio you receive from peers. It just gives you the data and forgets about it, leaving it up to you what you want to do with it.

  • you can play it back in Unity using an AudioSource
  • you can save it to disk
  • you can use it as input for a speech-to-text
  • stream it to a server

The most common use output source is playing it inside your app. An official output implementation that plays peer audio on Unity AudioSource is available here

Creating an audio output requires implementing two interfaces. They are IAudioOutput and IAudioOutputFactory

🌐 Network

You guessed it. UniVoice is network agnostic. This means, it doesn't care how the audio is exchanged between peers. It just needs a networking implementation of its IChatroomNetwork interface, which allows you to adapt it to different kinds of network infra.

  • you can send audio over WLAN
  • or webrtc
  • or popular networking solution providers such as Photon
  • or your own custom backend solution

Creating your own network requires you to implement the IChatroomNetwork interface

Docs

Manuals and sample projects are not available yet. For the API reference, please visit http://www.vatsalambastha.com/univoice

License and Support

This project is under the MIT license.

Updates and maintenance are not guaranteed and the project is maintained by the original developer in his free time. Community contributions are welcome.

Commercial consultation and development can be arranged but is subject to schedule and availability.

Contact

The developer can be reached at the following links:

Website
LinkedIn
GitHub
Twitter

More Repositories

1

tork

Arcade vehicle physics for Unity
C#
428
star
2

GPUVideoPlayer

Fast video playback on Unity using GPU Decoding
C++
128
star
3

unimic

Unity's Microphone class, enhanced.
C#
111
star
4

unex

Unity3D, extended. Includes hotkeys, C# extensions, utilities and more.
C#
61
star
5

UniGOAP

A work-in-progress Unity3D solution for intellignt NPCs for use in video games, simulations and similar media.
C#
57
star
6

UniDLL

Editor window to create DLLs from C# code in Unity
C#
51
star
7

airpeer

A WebRTC based networking plugin for Unity
C#
48
star
8

UniLang

Translate text from one language to another using Google Translate
C#
37
star
9

UniVRMedia

Stream 360 videos in Unity using its VideoPlayer component entirely through code and not editor setup.
C#
33
star
10

UniCV

[WIP] OpenCV for Unity with boilerplate code
C#
26
star
11

mediaplayer

A standardised media player interface for Unity with subtitle parser.
C#
21
star
12

upm-template

A template for making UPM based Unity packages
20
star
13

UniCull

[WIP] A renderer culling library for Unity. Includes distance based frustum culling. Hoping to make screen space occlusion culling too.
C#
16
star
14

RestSharp.Unity

A UPM package for RestSharp with some extensions and extra stuff.
C#
15
star
15

UniSpeech

A simple to use Speech Recognition library for Unity based on the Microsoft Cognitive Services
C#
15
star
16

ugx

UGX: UGUI Extended is a high-level library over Unity's inbuilt uGUI.
C#
12
star
17

univoice-sample

A sample voice chat app using univoice
C#
11
star
18

BeneDict

A code generating wizard that works on Fredrik Ludvigsen's SerializableDictionary on wiki.unity3d.com
C#
10
star
19

UniSpline

A Unity tool for creating curves
C#
9
star
20

airsignal

Node base WebRTC Signalling server. Used with AirPeer.
8
star
21

Xavier

A Networking solution for Unity based on Telepathy
C#
8
star
22

UniFace

A C# API for modifying UV spaces in Unity3D
C#
7
star
23

trill

Data transmission using sound waves
C#
6
star
24

unity-3.x-car-tutorial

The good old Unity car tutorial.
C#
6
star
25

univoice-mirror-network

A Mirror based implementation for UniVoice voice network
C#
6
star
26

mongodb.entities.unity

A UPM package of MongoDB.Entities for the Unity game engine
C#
5
star
27

UniDecal

🚧 A real-time + baked decal solution for Unity
5
star
28

surge.tween

UPM project for Tween features in the Surge toolset by Pixel Placement
C#
4
star
29

univoice-unimic-input

C#
4
star
30

UniStream

Read/Write Unity objects from/to byte streams
C#
4
star
31

UniGenVR

Make interactive VR experiences for mobile devices without writing any (or much) code
C#
3
star
32

CsvUtility

A small tool for reading CSV files in C#. Made for Unity
C#
3
star
33

univoice-audiosource-output

C#
3
star
34

UniCDN

CDN adapter for Unity. Currently supports PlayerIO GameFS CDN out of the box
C#
3
star
35

adrenak.github.io

Personal website
CSS
2
star
36

github-gameoff-2020

Entry for the Github Gameoff game jam 2020. Retro fighter jet game.
C#
2
star
37

univoice-telepathy-network

C#
2
star
38

AmazonFlingUnity

A Unity wrapper over Amazon Fling SDK to cast videos to FireTV and Firestick devices. Currently supports only Android and only second screen applications (phone controller/remote).
C#
2
star
39

vboard

C#
1
star
40

spatial

C#
1
star
41

utf8json

A UPM friendly repo of utf8json for Unity
C#
1
star
42

NewMorning

A quick VR game made with primitive Unity models, NewtonVR for Oculus Rift (and other VR devices)
C#
1
star