Voice Intro


Getting Started

Photon Voice 2 is the successor of Photon Voice which brings the following:

  • Improved API with better Unity components.
  • Compatibility with PUN2.
  • Flexibility: since now it is decoupled from PUN2, it can be used (always inside Unity) with Photon Realtime, Photon Bolt, Photon Chat or even standalone.
  • New WebRTC based DSP.
  • New updated demos.

Key Components


A VoiceConnection component instance is required in the scene to be able to connect a voice client to Photon Servers. Since voice transmission is possible only inside rooms, the VoiceConnection is used to do the matchmaking and making sure the client is joined to a room.


Since the Recorder is a very important component it has its own dedicated page here.


The Speaker component is responsible for playing the incoming audio stream. It makes use of Unity's AudioSource component. The component doesn't make much sense on its own outside a context of a voice stream or before getting the information of an incoming stream via its creation event. That event and the data it contains are important to 'link' a local Speaker component to a remote voice stream. In the following section we will explain how the Speaker should be used.


The SpeakerFactory method will be called every time a new remote voice stream info is received. The SpeakerFactory's role is to link or bind incoming remote voice streams (transmitted via Recorder component instances) with local Speaker component instances. We support a one-to-one relationship between a remote voice stream and local Speaker or a remote Recorder and local Speaker. By default, you cannot mix and play multiple incoming audio streams using a single Speaker component instance. Also, by default, you cannot play a single incoming audio stream using multiple Speaker component instances.

In the factory, you need to return a Speaker component that will be used to play the received audio frames from that remote voice stream. You could create a new Speaker component or re use an old one or just return null to skip playing all future incoming audio frames from that same remote voice stream.

Default SpeakerFactory

If you do not explicitly set a SpeakerFactory then the default one VoiceConnection.SimpleSpeakerFactory will be used. The default VoiceConnection.SimpleSpeakerFactory guarantees that there is a Speaker instantiated locally per remote voice stream. If you set a SpeakerPrefab then that prefab will be instantiated as a root object in the hierarchy at default position with default rotation. Otherwise a new GameObject will be created. The GameObject to which the Speaker component is attached to will be renamed to "Speaker for Player {0} Voice #{1}" and will be destroyed when the remote voice stream will be removed.

How To Use Voice (Without PUN)

  1. Add a VoiceConnection component to the scene
  2. Set AppSettings in VoiceConnection.Settings
  3. Add a Recorder to the scene, update its properties and assign it to VoiceConnection.PrimaryRecorder.
  4. Decide how to link Speaker components with remote voice streams:
    4.a. Optionally implement a SpeakerFactory method and assign it to VoiceConnection.SpeakerFactory by code.
    4.b. If you use the default SpeakerFactory, optionally add a Speaker prefab (a prefab that has a Speaker component) and assign it VoiceConnection.SpeakerPrefab.
  5. Join a room. To do so use any of Photon Realtime's matchmaking operations (see "ConnectAndJoin.cs" utility script for example)
  6. Once in a room start transmitting by setting Recorder.TransmitEnabled = true.
  7. Optionally enable Recorder.DebugEchoMode on the transmitting recorder to hear yourself.

How To Remove PUN

If you want to use Photon Voice without PUN, you can keep PUN inside your project or simply remove it by following these steps:

  1. Delete "Demos\DemoVoicePUN" folder
  2. Delete "Photon\PhotonVoice\Code\PUN" folder
  3. Delete "Photon\PhotonUnityNetworking" folder
  4. While this should be done for you, make sure that in "Project Settings" -> "Player" > "Other Settings" > "Scripting Define Symbols", PHOTON_UNITY_NETWORKING, all PUN_2_X_OR_NEWER and PUN_2_OR_NEWER are removed.

How To Remove Photon Chat

If you want to use Photon Voice without Photon Chat, you can keep Photon Chat inside your project or simply remove it simply deleting "Photon\PhotonChat" folder.