Skip to main content

thai backchannel classifier - detect backchannels vs real responses in thai asr output

Project description

thai backchannel classifier

detects thai backchannel responses (fillers like ครับ, ค่ะ, อืม) vs real user input for voice ai systems.

why

thai voice bots using asr → llm → tts pipelines need to distinguish between backchannels (acknowledgment sounds that should be ignored) and real responses that need processing. simple exact matching fails on asr variants and misses edge cases.

approach

gradient boosting classifier with 23 handcrafted thai-specific features:

feature importance
remaining_ratio 0.9098
has_request 0.0406
has_negation 0.0274
particle_ratio 0.0108

key idea: strip known backchannel components from the text, measure what's left (remaining_ratio). if nothing remains, it's a backchannel.

features

  • remaining_ratio: strips known backchannel components, measures residual text
  • polite particle detection (ครับ/ค่ะ/จ้ะ variants)
  • backchannel sound patterns (อืม/อ๋อ/เออ with tone variants)
  • question/negation/request/continuation markers
  • handles asr misspellings (ค่า→ค่ะ, คับ→ครับ, อื้ม→อืม)

results

cross-validation

  • 99.49% f1 (5-fold cv, gradient boosting)
  • logistic regression baseline: 98.97% f1

full training set

               precision    recall  f1-score   support
real_response       1.00      1.00      1.00        96
  backchannel       1.00      1.00      1.00       194
     accuracy                           1.00       290

test suite: 94/94 (100%)

the test suite (tests/test_classifier.py) covers:

backchannels (49 cases):

  • basic polite particles: ครับ, ค่ะ, คับ, คะ, จ้ะ, จ้า
  • dai + particle: ได้ครับ, ได้ค่ะ, ได้จ้ะ
  • filler sounds: อืม, อือ, อื้อ, เออ, เอ่อ, อ่า
  • oh: อ๋อ, อ๋อครับ, อ๋อค่ะ
  • agreement: ใช่, จริง, ถูก, แน่นอน
  • ok variants: โอเคครับ, โอเคค่ะ
  • question-like: เหรอ, หรอ, งั้นเหรอ
  • compound: ครับ ฮัลโหล, อ่ะ ใช่ๆๆ, อ่าฮะ ครับ
  • asr tone variants: อื้ม, อ๊าา, อ้า, อึม

real responses (45 cases):

  • greetings: สวัสดีครับ, ขอบคุณครับ
  • negations: ไม่ครับ, ไม่ใช่ค่ะ, ยังครับ
  • questions: ราคาเท่าไหร่ครับ, ทำไมครับ, กี่โมงครับ
  • requests: ผมต้องการจองตั๋วครับ, ช่วยเช็คให้หน่อยได้ไหมครับ
  • tricky edge cases (backchannel + continuation):
    • "ใช่ แต่ว่า" → real (has continuation marker)
    • "ครับ แล้วก็" → real
    • "ได้ครับ แต่ขอเปลี่ยนวัน" → real
    • "อ๋อ แล้วเรื่องที่สอง" → real
    • "อืม แต่ว่าผมไม่แน่ใจ" → real
  • short real: ไม่, ยัง, เอา, ได้เลย

usage

from detect import is_backchannel

is_bc, confidence = is_backchannel("ครับ")        # (True, 1.0)
is_bc, confidence = is_backchannel("ไม่ครับ")     # (False, 0.0)
is_bc, confidence = is_backchannel("ใช่ แต่ว่า")  # (False, 0.0)

cli:

python detect.py ครับ
# 'ครับ' -> BACKCHANNEL (confidence: 1.0000)

testing

python -m pytest tests/ -v

or without pytest:

python tests/test_classifier.py

files

  • train.py - training script with all data + features
  • detect.py - inference module (import or cli)
  • backchannel_model.pkl - trained model (~50kb)
  • tests/test_classifier.py - comprehensive test suite (94 cases)

requirements

  • python 3.8+
  • scikit-learn
  • numpy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thai_backchannel-0.3.0.tar.gz (83.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thai_backchannel-0.3.0-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

File details

Details for the file thai_backchannel-0.3.0.tar.gz.

File metadata

  • Download URL: thai_backchannel-0.3.0.tar.gz
  • Upload date:
  • Size: 83.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for thai_backchannel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 889748a4d70b7091f221dd75a0458f1454e944dda294496437fff180971baf31
MD5 56659c609bb764596c447078952dc47c
BLAKE2b-256 d5f8c0936b9bc4050e90904d4b41defa2f4029ba962e4e6e2a30eb9f0c0966d5

See more details on using hashes here.

File details

Details for the file thai_backchannel-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for thai_backchannel-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b13bf8695f23a60324a8755345f01d315833af75d2cb619908079b2bdfdbfe7f
MD5 f3a0edf66167e8f7d67a3e552b656173
BLAKE2b-256 7da8410a98f92b1374fdebb33c6eecd04619bcf682782b76cbfae45b78833bc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page