The Acoustic Echo Cancellation (AEC) template demonstrates how to use our AEC primitive to filter out speaker echo.
Without AEC, if you’re not using headphones, the character’s voice may be fed back into the STT input.
The AEC module works only with the local model and uses CPU processing only.
Run the Template
- Go to Assets/InworldRuntime/Scenes/Primitivesand play theAECTemplatescene.  
- When the game starts, play the two example audio clips (FarendandNearend).
The far-end audio comes from the speaker; the near-end audio is captured by the microphone.
- Press Generateto produce the filtered audio.
- Then press Playto hear the result.
Understanding the Template
Structure
- This demo has only one prefab under InworldController:AEC. It containsInworldAECModule.
- When InworldControllerinitializes, it callsInitializeAsync()on the AEC module (see Primitives Overview).
- This creates an AECFactory, which then creates anAECInterfacebased on the currentAECConfig.
 
Workflow
Pressing the Generate button invokes AECCanvas.FilterAudio().
It first converts the two audio clips (Farend and Nearend) into AudioChunks, then calls InworldController.AEC.FilterAudio() to generate the filtered audio.
public void FilterAudio()
{
    AudioChunk farendChunk = WavUtility.GenerateAudioChunk(m_Farend);
    AudioChunk nearendChunk = WavUtility.GenerateAudioChunk(m_Nearend);
    m_FilteredChunk = InworldController.AEC.FilterAudio(nearendChunk, farendChunk);
    if (m_FilteredChunk == null) 
        return;
    if (m_CompleteText)
        m_CompleteText.text = "Audio Generated!";
    if (m_PlayFilteredButton)
        m_PlayFilteredButton.interactable = true;
}