Create a dynamic voice energy meter
Learn how to create a visual meter showing voice activity.
読み終わるまでの所要時間 2 分最終更新 5ヶ月前
Some application features might require a real-time visual representation of audio energy levels, sometimes called a Voice Unit (VU) meter. For example, this might be needed for a microphone check.
By default, the Vivox SDK is set up to support a simple speaking or not-speaking indicator for channel participants that is based on whether voice activity is detected; for that use case, you can iterate over IChannelSession::Participants() and check for SpeechDetected() or handle IChannelSession.EventAfterParticipantUpdated events to be notified when a participant's speaking state changes. Real-time capability requires one extra step.
Setting a "participant updated" event frequency for a speaking activity
To create a dynamic voice activity indicator, call ILoginSession::SetParticipantSpeakingUpdateRate() with a value of , , or . When set to one of these values, IChannelSession.EventAfterParticipantUpdated events are raised for each participant in each channel up to 1, 5, or 10 times per second, respectively, if the audio energy or other state has changed since the last event.
ParticipantSpeakingUpdateRateUpdate1HzUpdate5HzUpdate10HzDue to the sensitivity on most microphones, audio energy fluctuates near continuously unless the participant has fully muted their microphone (by SDK, OS, or hardware), resulting in no audio energy or speaking state changes. Similarly, does not increase the rate when joined to a channel text-only because energy and speaking state changes do not occur.
SetParticipantSpeakingUpdateRate()EventAfterParticipantUpdatedDisabling a "participant updated" event frequency for a speaking activity
Calling ILoginSession::SetParticipantSpeakingUpdateRate() with a value of prevents EventAfterParticipantUpdated events from getting raised due to changes in speech detection or changes in audio energy. If you are not displaying any UI related to speaking notifications or energy and do not need to track it for any other reason, this setting eliminates the minimal overhead that the setting involves. The separate events for a participant joining or leaving a channel continue to occur, and participants continue to get property change events when text or audio is enabled/disabled or when muted or unmuted, but events related to speaking activity do not occur, and the IParticipantProperties values for and are no longer updated and remain at their last known value.
ParticipantSpeakingUpdateRate::NeverStateChangeSpeechDetected()AudioEnergy()