語音活動檢測
串流音波及其衍生類型(如可捕捉音波)支援語音活動檢測(VAD)。VAD 會過濾傳入的音訊資料,僅在檢測到語音時才填入內部緩衝區。
該外掛提供兩種 VAD 實作:
- 預設 VAD
- Silero VAD
預設實作使用 libfvad,這是一個輕量級的語音活動檢測函式庫,可在 Runtime Audio Importer 支援的所有平台和引擎版本上高效運作。
Silero VAD 作為擴充外掛提供,是一種基於神經網路的語音活動檢測器,可提供更高的準確性,特別是在嘈雜環境中。它使用機器學習來更可靠地區分語音與背景噪音。
基本用法
在建立音波後,若要啟用 VAD,請使用 ToggleVAD 函式:
- 藍圖
- C++

// Assuming StreamingSoundWave is a UE reference to a UStreamingSoundWave object (or its derived type, such as UCapturableSoundWave)
StreamingSoundWave->ToggleVAD(true);
啟用 VAD 後,您可以隨時重置它:
- Blueprint
- C++

// Reset the VAD
StreamingSoundWave->ResetVAD();
預設 VAD 設定
使用預設 VAD 提供者時,您可以透過變更 VAD 模式來調整其敏感度:
- Blueprint
- C++

// Set the VAD mode (only works with the default VAD provider)
StreamingSoundWave->SetVADMode(ERuntimeVADMode::VeryAggressive);
mode 參數控制 VAD 過濾音訊的積極程度。數值越高越嚴格,意味著誤報的可能性較低,但可能會遺漏部分語音。
VAD 提供者
使用 ToggleVAD 函數啟用 VAD 後,您可以根據需求選擇不同的語音活動檢測提供者。預設提供者為內建,而其他提供者(如 Silero VAD)則可透過擴充外掛程式取得。
- 藍圖
- C++

// Assuming StreamingSoundWave is a UE reference to a UStreamingSoundWave object (or its derived type, such as UCapturableSoundWave)
// Make sure to call ToggleVAD(true) before setting the provider
// Set the VAD provider to Silero VAD
StreamingSoundWave->SetVADProvider(URuntimeSileroVADProvider::StaticClass());
Silero VAD 擴充功能
Silero VAD 使用神經網路提供更準確的語音偵測。使用方法如下:
-
確保您的專案中已安裝 Runtime Audio Importer 插件
-
適用於 UE 5.5 及更早版本: 在下載 Silero VAD 擴充功能插件之前,請確保您的專案中已停用 NNERuntimeORT。啟用 NNERuntimeORT 可能會因衝突而導致在這些引擎版本上使用 Silero VAD 時發生崩潰
-
從此處下載 Silero VAD 擴充功能插件
-
將下載的壓縮檔中的資料夾解壓縮到您專案的
Plugins資料夾中(如果該資料夾不存在,請建立它) -
適用於 UE 5.6 及更新版本: 編輯
RuntimeAudioImporterSileroVAD.uplugin檔案以新增 NNERuntimeORT 依賴項。在 "Plugins" 欄位中,於 RuntimeAudioImporter 包含項之後,新增:
,
{
"Name": "NNERuntimeORT",
"Enabled": true
}
- 重建您的專案(此擴充功能需要 C++ 專案)
-
預設的 VAD 適用於 Runtime Audio Importer 支援的所有引擎版本(UE 4.24、4.25、4.26、4.27、5.0、5.1、5.2、5.3、5.4、5.5、5.6、5.7 和 5.8)
-
Silero VAD 支援 Unreal Engine 4.27 及所有 UE5 版本(4.27、5.0、5.1、5.2、5.3、5.4、5.5、5.6、5.7 和 5.8)
-
UE 5.5 及更早版本: 使用 Silero VAD 前必須停用 NNERuntimeORT,以防止因外掛衝突而導致崩潰。特別是在 UE 5.3 中,也必須停用 NNERuntimeORTCpu 和 NNERuntimeORTGpu
-
UE 5.6+ 需求: 從 Unreal Engine 5.6 開始,Silero VAD 擴充功能需要手動將 NNERuntimeORT 外掛依賴項新增至
.uplugin檔案中 -
Silero VAD 可用於 Windows、Linux、Mac、Android(包括 Meta Quest)和 iOS
-
此擴充功能以原始碼形式提供,需要使用 C++ 專案
-
有關如何手動建置外掛的更多資訊,請參閱建置外掛教學
安裝完成後,您可以使用 SetVADProvider 函數並選擇 Silero 類別提供者,將其選為您的 VAD 提供者。
語音開始與結束偵測
語音活動偵測不僅能偵測語音的存在,還能偵測語音活動的開始與結束。這對於在播放或擷取過程中,於語音開始或結束時觸發事件非常有用。
您可以透過調整參數(例如最小語音持續時間和靜音持續時間)來自訂語音開始與結束偵測的靈敏度。這些參數有助於微調偵測,以避免誤判,例如捕捉到短暫的噪音或語音之間過短的停頓。
最小語音持續時間
最小語音持續時間 參數設定了觸發語音開始事件所需的最短連續語音活動時間。這有助於過濾不應被視為語音的短暫噪音,確保僅識別持續的語音活動。最小語音持續時間 的預設值為 300 毫秒。
- Blueprint
- C++

// Assuming StreamingSoundWave is a UE reference to a UStreamingSoundWave object (or its derived type, such as UCapturableSoundWave)
// Set the minimum speech duration
StreamingSoundWave->SetMinimumSpeechDuration(200);
靜音持續時間
靜音持續時間參數設定觸發語音結束事件所需的靜音持續時間。這可以防止語音偵測在單詞或句子之間的自然停頓中過早結束。靜音持續時間的預設值為 500 毫秒。
- Blueprint
- C++

// Assuming StreamingSoundWave is a UE reference to a UStreamingSoundWave object (or its derived type, such as UCapturableSoundWave)
// Set the silence duration
StreamingSoundWave->SetSilenceDuration(700);
綁定到語音委派
您可以在語音開始或結束時綁定到特定的委派。這對於根據語音活動觸發自訂行為非常有用,例如開始或停止文字辨識,或調整其他音訊來源的音量。
- 藍圖
- C++

// Assuming StreamingSoundWave is a UE reference to a UStreamingSoundWave object (or its derived type, such as UCapturableSoundWave)
// Bind to the OnSpeechStartedNative delegate
StreamingSoundWave->OnSpeechStartedNative.AddWeakLambda(this, [this]()
{
// Handle the result when speech starts
});
// Bind to the OnSpeechEndedNative delegate
StreamingSoundWave->OnSpeechEndedNative.AddWeakLambda(this, [this]()
{
// Handle the result when speech ends
});