fix(voice): raise the consonant band by 12 dB before transcription

A dark microphone or a speaker who swallows first consonants and
sentence ends loses the band above 1 kHz first: in the live
recordings "자비스" came out as "아비스"/"다비스" and "서울" as "어우".
loudness_equalise now raises it with a one-octave shelf at 1 kHz.

Measured with large-v3-turbo: 25 sure live utterances 5.0% -> 3.4% CER,
FLEURS Korean test split (382 clips, held out) 5.16% -> 4.98%. The real
noise check stays at 108 clips with no text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-18 18:09:05 +09:00
parent e428aad58a
commit 9f62bfb059
4 changed files with 34 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ from __future__ import annotations
import numpy as np
import pytest
from voice_worker.audio import InputConverter, loudness_equalise
from voice_worker.audio import HIGH_SHELF_DB, HIGH_SHELF_HZ, InputConverter, loudness_equalise
from voice_worker.protocol import (KIND_AUDIO, KIND_TTS, ProtocolError, decode_audio_frame, encode_audio_frame,
encode_tts_frame, decode_tts_frame)
@@ -171,3 +171,16 @@ def test_low_rumble_is_removed_before_levelling():
spec = np.abs(np.fft.rfft(y))
freqs = np.fft.rfftfreq(len(y), 1 / 16000)
assert spec[np.argmin(np.abs(freqs - 30))] < 0.01 * spec[np.argmin(np.abs(freqs - 220))]
@pytest.mark.unit
def test_consonant_band_is_raised_against_the_vowel_band():
"""A dark microphone (or a speaker who swallows consonants) loses the band above 1 kHz where
"ㅈ" and "ㅅ" live; it is raised by the shelf, the band below it is left as it was."""
t = np.arange(32000) / 16000
low, high = HIGH_SHELF_HZ / 4, HIGH_SHELF_HZ * 4
x = (0.05 * np.sin(2 * np.pi * low * t) + 0.05 * np.sin(2 * np.pi * high * t)).astype(np.float32)
spec = np.abs(np.fft.rfft(loudness_equalise(x)))
freqs = np.fft.rfftfreq(len(x), 1 / 16000)
ratio_db = 20 * np.log10(spec[np.argmin(np.abs(freqs - high))] / spec[np.argmin(np.abs(freqs - low))])
assert abs(ratio_db - HIGH_SHELF_DB) < 0.5