|
|
|
|
@ -492,7 +492,7 @@ int radio_audio_capture_start(uint64_t group_id, int capture_channels, int vad_e
|
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_RADIO, "%s: silero_vad_create_default failed — VAD auto-PTT disabled", RADIO_AUDIO_ID); |
|
|
|
|
} |
|
|
|
|
if (!g_vad_mode && g_vad_compressor) { audio_compressor_destroy(g_vad_compressor); g_vad_compressor = NULL; } |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "VAD config group=%016llx requested=%d ready=%d ch=%d threshold=%.3f confirm=%dx32ms " |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_VAD, "VAD config group=%016llx requested=%d ready=%d ch=%d threshold=%.3f confirm=%dx32ms " |
|
|
|
|
"hangover=%dms busy_hold=%dms prefetch=%dms compressor=%s max_gain=%.0fdB target=%.1fdBFS " |
|
|
|
|
"history=%dms rise=%.1fx release=%.1fx block=%dms buffering=%dms", (unsigned long long)group_id, |
|
|
|
|
vad_enabled, g_vad_mode, capture_channels, g_vad_threshold, RADIO_VAD_CONFIRM_WINDOWS, |
|
|
|
|
@ -529,7 +529,7 @@ int radio_audio_capture_start(uint64_t group_id, int capture_channels, int vad_e
|
|
|
|
|
void radio_audio_capture_stop(void) { |
|
|
|
|
radio_tx_lock(); |
|
|
|
|
if (g_encoder) { |
|
|
|
|
if (g_vad_mode) DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "VAD capture stop group=%016llx windows=%llu talking=%d manual=%d " |
|
|
|
|
if (g_vad_mode) DEBUG_INFO(DEBUG_CATEGORY_VAD, "VAD capture stop group=%016llx windows=%llu talking=%d manual=%d " |
|
|
|
|
"transmitting=%d confirm=%d window_tail=%d pcm_tail=%d gain=%.1fdB", |
|
|
|
|
(unsigned long long)g_group_id, (unsigned long long)g_vad_diag.total_windows, |
|
|
|
|
g_vad_fsm.talking, g_vad_manual_ptt, g_transmitting, g_vad_fsm.confirm_count, |
|
|
|
|
@ -630,7 +630,7 @@ static void radio_audio_talk(void* arg) {
|
|
|
|
|
if (talk->begin) { |
|
|
|
|
uint64_t age_tb = get_time_tb() - talk->created_tb; |
|
|
|
|
if (!current || age_tb > 2000) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VAD/PTT BEGIN discarded group=%016llx generation=%llu burst=%llu " |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_RADIO, "VAD/PTT BEGIN discarded group=%016llx generation=%llu burst=%llu " |
|
|
|
|
"owner=%d current=%d queue_age=%.1fms limit=200ms", (unsigned long long)talk->group_id, |
|
|
|
|
(unsigned long long)talk->generation, (unsigned long long)talk->burst, owner, current, age_tb / 10.0); |
|
|
|
|
return; |
|
|
|
|
@ -638,10 +638,10 @@ static void radio_audio_talk(void* arg) {
|
|
|
|
|
int rc = radio_talk_begin(talk->inst, talk->group_id); |
|
|
|
|
if (rc == 0) { |
|
|
|
|
g_net_generation = talk->generation; g_net_burst = talk->burst; g_net_group = talk->group_id; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VAD/PTT BEGIN dispatched group=%016llx generation=%llu burst=%llu queue_age=%.1fms", |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_RADIO, "VAD/PTT BEGIN dispatched group=%016llx generation=%llu burst=%llu queue_age=%.1fms", |
|
|
|
|
(unsigned long long)talk->group_id, (unsigned long long)talk->generation, |
|
|
|
|
(unsigned long long)talk->burst, age_tb / 10.0); |
|
|
|
|
} else DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "VAD/PTT BEGIN failed group=%016llx rc=%d queue_age=%.1fms", |
|
|
|
|
} else DEBUG_WARN(DEBUG_CATEGORY_RADIO, "VAD/PTT BEGIN failed group=%016llx rc=%d queue_age=%.1fms", |
|
|
|
|
(unsigned long long)talk->group_id, rc, age_tb / 10.0); |
|
|
|
|
} else if (g_net_generation == talk->generation && g_net_burst == talk->burst && g_net_group == talk->group_id) { |
|
|
|
|
if (owner) radio_talk_end(talk->inst, talk->group_id); |
|
|
|
|
@ -786,7 +786,7 @@ static void radio_audio_update_transmission(void) {
|
|
|
|
|
} |
|
|
|
|
if (radio_audio_post_talk(g_inst ? g_inst->ua : NULL, g_group_id, desired) != 0) { u_free(prefetch); return; } |
|
|
|
|
g_transmitting = desired; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "%s: TX %s generation=%llu burst=%llu manual=%d vad=%d", RADIO_AUDIO_ID, |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "%s: TX %s generation=%llu burst=%llu manual=%d vad=%d", RADIO_AUDIO_ID, |
|
|
|
|
desired ? "BEGIN" : "FIN", (unsigned long long)g_tx_generation, (unsigned long long)g_tx_burst, |
|
|
|
|
g_vad_manual_ptt, g_vad_fsm.talking); |
|
|
|
|
if (desired && g_vad_mode) radio_audio_send_prefetch(prefetch); |
|
|
|
|
@ -795,7 +795,7 @@ static void radio_audio_update_transmission(void) {
|
|
|
|
|
void radio_audio_capture_discontinuity(uint64_t group_id) { |
|
|
|
|
radio_tx_lock(); |
|
|
|
|
if (g_active && g_group_id == group_id && g_encoder) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "%s: capture discontinuity tail=%d transmitting=%d vad_tail=%d vad_gain=%.1fdB", |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_RADIO, "%s: capture discontinuity tail=%d transmitting=%d vad_tail=%d vad_gain=%.1fdB", |
|
|
|
|
RADIO_AUDIO_ID, g_tx_pcm_frames, g_transmitting, g_vad_pcm_frames, audio_compressor_gain_db(g_vad_compressor)); |
|
|
|
|
radio_audio_flush_tx(); |
|
|
|
|
g_vad_win_len = g_vad_decimation = 0; g_vad_sum = 0; |
|
|
|
|
@ -844,7 +844,7 @@ static void radio_audio_vad_sample(const int16_t* frame) {
|
|
|
|
|
if (gap_tb > g_vad_diag.max_gap_tb) g_vad_diag.max_gap_tb = gap_tb; |
|
|
|
|
if (result != 0) { |
|
|
|
|
++g_vad_diag.errors; |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "VAD inference failed group=%016llx window=%llu rc=%d inference=%.1fms", |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_VAD, "VAD inference failed group=%016llx window=%llu rc=%d inference=%.1fms", |
|
|
|
|
(unsigned long long)g_group_id, (unsigned long long)g_vad_diag.total_windows, result, inference_tb / 10.0); |
|
|
|
|
} |
|
|
|
|
struct radio_vad_fsm before = g_vad_fsm; |
|
|
|
|
@ -861,7 +861,7 @@ static void radio_audio_vad_sample(const int16_t* frame) {
|
|
|
|
|
radio_audio_update_transmission(); |
|
|
|
|
if (transition || busy != g_vad_diag.last_busy || before.confirm_count != g_vad_fsm.confirm_count || |
|
|
|
|
!!before.silence_since_tb != !!g_vad_fsm.silence_since_tb) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VAD decision group=%016llx window=%llu reason=%s probability=%.3f threshold=%.3f " |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_VAD, "VAD decision group=%016llx window=%llu reason=%s probability=%.3f threshold=%.3f " |
|
|
|
|
"talking=%d->%d confirm=%d->%d/%d silence=%.1f/%dms busy=%d rx_node=%016llx rx_age=%lldms " |
|
|
|
|
"manual=%d transmitting=%d input=%.1fdBFS model=%.1fdBFS gain=%.1fdB inference=%.1fms gap=%.1fms", |
|
|
|
|
(unsigned long long)g_group_id, (unsigned long long)g_vad_diag.total_windows, reason, probability, g_vad_threshold, |
|
|
|
|
@ -871,7 +871,7 @@ static void radio_audio_vad_sample(const int16_t* frame) {
|
|
|
|
|
20.0f * log10f(fmaxf(model_rms, 0.000001f)), audio_compressor_gain_db(g_vad_compressor), |
|
|
|
|
inference_tb / 10.0, gap_tb / 10.0); |
|
|
|
|
} |
|
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_DEBUG, "VAD window=%llu reason=%s probability=%.4f model_rms=%.6f peak=%.6f " |
|
|
|
|
DEBUG_TRACE(DEBUG_CATEGORY_VAD, "VAD window=%llu reason=%s probability=%.4f model_rms=%.6f peak=%.6f " |
|
|
|
|
"input_rms=%.6f agc_rms=%.6f confirm=%d talking=%d busy=%d manual=%d tx=%d inference=%.1fms gap=%.1fms", |
|
|
|
|
(unsigned long long)g_vad_diag.total_windows, reason, probability, model_rms, peak, g_vad_input_rms, g_vad_output_rms, |
|
|
|
|
g_vad_fsm.confirm_count, g_vad_fsm.talking, busy, g_vad_manual_ptt, g_transmitting, inference_tb / 10.0, gap_tb / 10.0); |
|
|
|
|
@ -885,7 +885,7 @@ static void radio_audio_vad_sample(const int16_t* frame) {
|
|
|
|
|
if (model_rms > g_vad_diag.max_model_rms) g_vad_diag.max_model_rms = model_rms; |
|
|
|
|
if (!g_vad_diag.stats_tb) g_vad_diag.stats_tb = now; |
|
|
|
|
if (now - g_vad_diag.stats_tb >= RADIO_AUDIO_STATS_TB) { |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "VAD summary group=%016llx span=%.1fms windows=%u audio=%ums speech=%u " |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_VAD, "VAD summary group=%016llx span=%.1fms windows=%u audio=%ums speech=%u " |
|
|
|
|
"busy=%u confirm_resets=%u errors=%u probability=%.3f..%.3f threshold=%.3f reason=%s " |
|
|
|
|
"input_peak=%.1fdBFS model_peak=%.1fdBFS gain=%.1fdB clips=%u inference_max=%.1fms gap_max=%.1fms " |
|
|
|
|
"manual=%d talking=%d tx=%d tx_pending=%u control_pending=%u dropped=%u", |
|
|
|
|
@ -916,7 +916,7 @@ static void radio_audio_vad_feed(const int16_t* frame) {
|
|
|
|
|
g_vad_input_rms = sqrtf((float)(g_vad_input_sum_sq / count)); |
|
|
|
|
g_vad_pcm_frames = 0; g_vad_input_sum_sq = 0; |
|
|
|
|
if (audio_compressor_process_frame(g_vad_compressor, g_vad_pcm, g_vad_pcm, count) != 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_DEBUG, "%s: VAD compressor frame failed count=%d — auto-PTT disabled until capture restart", |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_VAD, "%s: VAD compressor frame failed count=%d — auto-PTT disabled until capture restart", |
|
|
|
|
RADIO_AUDIO_ID, count); |
|
|
|
|
g_vad_mode = 0; g_prefetch_write = g_prefetch_frames = 0; |
|
|
|
|
radio_vad_fsm_reset(&g_vad_fsm); |
|
|
|
|
|