I am not able to set the voice detection threshold
I am trying to set a threshold for the input in order to create some kind of visual feedback to show that a user is talking, but when i run my application the threshold is always set to zero. No matter if i try to set from the inspector or by code, it will remain zero. I also noticed that i actually CAN set the threshold as long as i don't set the primary recorder for the PunVoiceClient. Basically if i comment line 28 the threshold will be set correctly, but i obviously won't hear anything since i have no primary recorder.
Hi, unfortunatelly, I could not reproduce the described behaviour (it works ok in my test), but I have one suggestion - what happens, when you switch the lines, first set the newly created recorder as primary recorder and then setup the threshold?0
Hi, thank you for your reply.
Yes, i tried to switch the lines but sadly it did not work. Actually i tried a lot of different "stupid" things such as switching lines but none of them worked. The problem is REALLY weird, for example if i try to set other properties like VoiceDetectionDelayMs, it works!! It looks like everything works fine but the threshold. Is there any method i should call in order to make the change effective? i tried to call Recorder.RestartRecording() but it seems to have no effect.0
That is really weird. Could you pleasi specify, which version of PhotonVoiceSDK and PUN are you using? Also which Unity version. If possible, please try to use the latest version of Voice and PUN (Voice 2.50, PUN 2.41) and Unity 2019.4.39 and newer.
What about if you try to change the threshold later? In Start() or in fisrt Update()?0
When the StartRecording method is called for the first time in Update, it ends up calling StopRecording, which in turn calls GetThresholdFromDetector, which is the method responsible for changing the main threshold based on the Threshold of the voice detector. Voice detector has not been created yet (it will only be created later in CreateLocalVoiceAudioAndSource), it is as LocalVoiceAudioDummy.Dummy in this moment, which always has the value 0. Threshold value is changed to 0 because of this. I don't know whether it is really necessary to call GetThresholdFromDetector before the voicedector is initialized. Maybe the Recorder code should be changed.1
@GSirius you are correct, there is bug (that has already been fixed for the next release of Photon Voice). Any call of GetThresholdFromDetector and also the method itself in the Recorder can be removed. Only in VoiceDetectorCalibrate, the line using it needs to be replaced with 'this.voiceDetectionThreshold = this.VoiceDetector.Threshold;'
That should fix your issue @pide0