Voice Conversations
Push-to-talk NPC conversations with voice detection and automatic reply playback.
Voice runs over the same connection as text. The player talks, the SDK detects when they stop, the NPC replies out loud through the AudioSource that was added next to the component. You start and stop the conversation; everything in between is handled.
The conversation loop
Call ToggleConversation() (or StartConversation() / EndConversation() for explicit control) when the player engages the NPC. While the conversation is active the SDK listens to the microphone, uses voice activity detection to decide when the player has finished a sentence (a short stretch of silence ends the turn), sends the speech, and queues the spoken reply for playback. The reply text also arrives via OnNPCResponseReceived, and the player's own transcript via OnPlayerSpeechRecognized, so a subtitle log costs nothing extra.
using Mistscale.SDK;
using UnityEngine;
public class VoiceInteraction : MonoBehaviour
{
[SerializeField] private MistscaleNPC mira;
void Update()
{
// Talk to the NPC while looking at it and holding V
if (Input.GetKeyDown(KeyCode.V) && PlayerIsFacing(mira))
mira.ToggleConversation();
}
}Tuning voice detection
The voice component added next to MistscaleNPC exposes the detection knobs in the Inspector:
VoiceThresholdSilenceDurationSecsSampleRateReacting to voice state in your UI
The voice component raises events for every state change, which is everything you need for talk indicators, subtitles, or an animated microphone meter:
OnListeningStartedOnListeningStoppedOnVoiceStartedSpeakingOnVoiceStoppedSpeakingOnVoiceResponseReceivedOnVoiceResponseCompleteGetCurrentAudioLevel()