PhotonVoiceRecorder Source-AudioClip


I have a project which uses a speech recognizer, and Photon Voice. I set the photon voice recorded source to AudioClip,
then, i have a script which sets the voice recorder audioclip to another audioclip coming from the speech recognizer microphone. The problem is that i cannot hear anything from either of the clients.

Any ideas/suggestions?


  • vadim
    vadim mod
    edited May 2018
    PhotonVoiceRecorder's AudioClip is supposed to be used for files playback. Not sure what happens when you override it with your clip.

    To stream audio from custom source, set PhotonVoiceRecorder's Source to Factory in editor and tell PhotonVoice to use factory creating instance of your MyAudioSource class somewhere during app initialization (before PhotonVoiceRecorder created):
    PhotonVoiceNetwork.AudioSourceFactory = (rec) => new MyAudioSource();

    You have 2 options for MyAudioSource:
    1. Implement ExitGames.Client.Photon.Voice.IAudioReader interface. As long as client is connected to a voice room and PhotonVoiceRecorder is transmitting, Read(float[] buffer) method will be called on MyAudioSource instance. Read should return false if not enough data to fill the buffer exists. Existing samples should be preserved for the next 'Read' call. Calls frequency and buffer size are adjusted automatically to meet sampling rate returned by SamplingRate property of MyAudioSource. Look at AudioClipWrapper which streams audio clip assigned in editor.
    2. When data stream is driven not by consumer but by producer, it may be more convenient to use Voice.IAudioPusher interface. You need to implement SetCallback method only which mainly stores given callback. During streaming, you simply call this callback periodically with as many samples as you have. Photon Voice will do all buffering work for you. ToneAudioPusher in AudioUtil.cs is a sample of Voice.IAudioPusher usage