p99 và VAP — Mô hình luân phiên hội thoại

p99 ước tính xác suất kết thúc lượt nói từ một kênh âm thanh. VAP dự báo hoạt động giọng nói từ hai kênh đồng bộ của người dùng và trợ lý. Ứng dụng quyết định khi nào trả lời hoặc ngắt lời.

Biên dịch SDK từ mã nguồn để dùng các API này. Swift dùng SpeechVAD; C++ cần SPEECH_CORE_WITH_ONNX=ON. API Android dùng ONNX Runtime. Các thiết lập mặc định của luồng xử lý hiện có được giữ nguyên.

Mô hình

p99 turn-1-mini5.3M · CoreML · Float3216 kHz · 160 ms · 1 chApache-2.0
VAP (otoSpeech)5.8M · CoreML / ONNX · Float3216 kHz · 20 s · 2 chCC BY 4.0 / MIT

Swift API

p99 lưu đệm bước chưa đủ. Mỗi bước 160 ms trả về tám khung 20 ms. Dùng availableAfterSeconds làm thời điểm quyết định và đặt lại phiên giữa các cuộc hội thoại.

import SpeechVAD

let p99 = try await P99TurnModel.fromPretrained()
let session = try p99.createSession()
let frames = try session.pushAudio(pcm16k)
for frame in frames {
    print(frame.probability, frame.availableAfterSeconds)
}
try session.reset()

let vap = try await VAPModel.fromPretrained()
let forecast = try vap.forecast(userAudio: userPcm, agentAudio: agentPcm)
print(forecast.pNow, forecast.pFuture, forecast.voiceActivity)

VAP dùng 20 giây gần nhất ở 16 kHz. Hai kênh phải dài bằng nhau; dùng kênh toàn số 0 khi trợ lý im lặng. Đầu vào ngắn được thêm khoảng lặng ở đầu. Mỗi lần dự báo tính lại cả cửa sổ; chọn khoảng gọi phù hợp với thiết bị.

C++

#include <speech_core/models/onnx_vap.h>

speech_core::OnnxVap model("models/vap.onnx");
auto forecast = model.forecast(user.data(), agent.data(), user.size(), 16000);
// p_now[0]: user, p_now[1]: agent
// p_future and voice_activity use the same channel order.

Android

val directory = ModelManager.ensureVapModels(context)
withContext(Dispatchers.Default) {
    VoiceActivityProjection(VoiceActivityProjectionConfig(directory)).use { model ->
        val forecast = model.forecast(userPcm, agentPcm)
        println(forecast.userNearTerm)
        println(forecast.agentNearTerm)
    }
}

Tải xuống

Kết quả đo kiểm

TurnBench · Soniqo

Giấy phép