Detect when user is talking with VoiceDetection
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Voice.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Detect when user is talking with VoiceDetection
BFX
2020-04-10 12:51:35
I've activated VoiceDetection and regulated the threshold accordingly. It works well, I can clearly hear my voice being transmitted when talking and transmission being put on hold during silence. However, I need to fire some events connected to when the user is talking and I'm not able to do so.
These are my current Recorder settings --> https://ibb.co/K6wHLmg
And this is the code I'm using to detect when the user is talking:
public class VoiceEvents : MonoBehaviour
{
Recorder recorder;
PhotonVoiceView voiceView;
// Start is called before the first frame update
void Start()
{
// Audio is not transmitted by default
recorder = GetComponent<Recorder>();
voiceView = GetComponent<PhotonVoiceView>();
// recorder.TransmitEnabled = false;
}
// Update is called once per frame
void Update()
{
if (recorder.TransmitEnabled) {
Debug.Log("Talking");
} else {
Debug.Log("Silence");
}
}
}
My log is showing "Talking" all the time even during silence.
My Stack:
- Unity3D 2019.3
- Oculus Quest
- PUN2 Free - 2.17.1
- Photon Voice FREE 1.23
Comments
Hi @BFX,
Make sure Photon Voice version is correct!
It should be 2.15 and not 1.23.
You could use Recorder.VoiceDetector.Detected or Recorder.VoiceDetector.OnDetected.
Or Recorder.IsCurrentlyTransmitting.
By the way, you could get the Recorder in use from PhotonVoiceView.RecorderInUse.
Thanks a lot. We updated it and using Recorder.IsCurrentlyTransmitting. Now it's working well.
Back to top