Skip to main content

backchannel classifier - detect backchannels vs real responses in thai (incl. isan/northern/southern dialects) and japanese asr output

Project description

backchannel classifier

detects backchannel responses vs real user input for voice ai systems. supports thai (standard + อีสาน/เหนือ/ใต้ dialects) and japanese (aizuchi).

install

pip install backchannel-classifier

usage

from backchannel_classifier import is_backchannel

# thai (default)
is_backchannel("ครับ")                    # (True, 0.91)
is_backchannel("ไม่ครับ")                 # (False, 0.01)
is_backchannel("ใช่ แต่ว่า")              # (False, 0.01)

# thai dialects
is_backchannel("แม่นเด้อ")                # (True, 0.99)   อีสาน (isan)
is_backchannel("เจ้า")                    # (True, 0.99)   เหนือ (northern)
is_backchannel("จริงเหอ")                 # (True, 0.99)   ใต้ (southern)
is_backchannel("บ่ได้ครับ")               # (False, 0.001) isan negation = real response
is_backchannel("สวัสดีเจ้า")              # (False, 0.0001) northern greeting = real response

# japanese
is_backchannel("はい", lang="ja")         # (True, 0.99)
is_backchannel("そうですね", lang="ja")    # (True, 0.99)
is_backchannel("予約したいです", lang="ja") # (False, 0.0001)

# direct import
from backchannel_classifier.jp import is_backchannel_ja
is_backchannel_ja("なるほど")              # (True, 0.99)

returns (is_backchannel: bool, confidence: float).

why

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 handcrafted language-specific features. key idea: strip known backchannel components from the text, measure what's left (remaining_ratio). if nothing remains, it's a backchannel.

thai (28 features)

feature importance
remaining_ratio 0.8374
has_negation 0.0718
remaining_len 0.0293
particle_ratio 0.0208
has_wama 0.0120
  • polite particle detection (ครับ/ค่ะ/จ้ะ variants)
  • backchannel sound patterns (อืม/อ๋อ/เออ with tone variants)
  • question/negation/request/continuation markers
  • handles asr misspellings (ค่า→ค่ะ, คับ→ครับ, อื้ม→อืม)
  • dialect support:
    • อีสาน (isan): แม่น, เด้อ, เนาะ, โดย, อีหลี + บ่ negation, ไส/หยัง/ใด๋ questions
    • เหนือ (northern): เจ้า, ใจ้/ใจ่, แต๊, เน้อ, กา tags
    • ใต้ (southern): เหอ/หอ/หวา tags, แหละ, พันนั้นแหละ + พรื่อ questions

japanese (27 features)

feature importance
remaining_ratio 0.7765
remaining_len 0.0484
katakana 0.0347
word_count 0.0325
kanji_ratio 0.0206
  • core aizuchi (はい/ええ/うん/そう)
  • agreement, understanding, surprise, filler, reaction markers
  • question/continuation/request/negation/verb negative indicators
  • handles asr elongation variants (はーーい, えーーー)

results

thai

  • 99.26% f1 (5-fold cv)
  • test suite: 186/186 (100%)

japanese

  • 98.37% f1 (5-fold cv)
  • test suite: 119/119 (100%)

test coverage

thai (186 cases)

backchannels (102): ครับ, ค่ะ, อืม, ใช่, อ๋อ, เหรอ, ฮัลโหล, asr variants... dialect backchannels (48): แม่น, เด้อ, เนาะ (อีสาน) / เจ้า, ใจ้, แต๊ (เหนือ) / เหอ, หวา, แหละ (ใต้) real responses (76): สวัสดีครับ, ไม่ครับ, ราคาเท่าไหร่ครับ, dialect (บ่ได้ครับ, สวัสดีเจ้า, ว่าพรื่อครับ), edge cases (ใช่ แต่ว่า, แม่น แต่ว่า)...

japanese (119 cases)

aizuchi (63): はい, うん, そうですね, なるほど, へー, まじで, えーと, すごい, 承知しました, compounds... real responses (56): ありがとうございます, いくらですか, 予約したいです, edge cases (はい、質問があります, そうですね、でも...)...

testing

python3 -m pytest tests/ -v

files

  • backchannel_classifier/__init__.py - thai classifier + unified api
  • backchannel_classifier/jp.py - japanese classifier
  • train.py - thai training script
  • train_ja.py - japanese training script
  • tests/test_classifier.py - thai test suite (186 cases, incl. อีสาน/เหนือ/ใต้ dialects)
  • tests/test_classifier_ja.py - japanese test suite (119 cases)

requirements

  • python 3.8+
  • scikit-learn
  • numpy

memory

~3.7 MB per language model, lazy-loaded. if you only use thai, japanese model is never loaded (zero overhead).

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

backchannel_classifier-0.5.0.tar.gz (165.8 kB view details)

Uploaded Source

Built Distribution

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

backchannel_classifier-0.5.0-py3-none-any.whl (116.0 kB view details)

Uploaded Python 3

File details

Details for the file backchannel_classifier-0.5.0.tar.gz.

File metadata

  • Download URL: backchannel_classifier-0.5.0.tar.gz
  • Upload date:
  • Size: 165.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for backchannel_classifier-0.5.0.tar.gz
Algorithm Hash digest
SHA256 99644fb6f145525d9f7ad0c1082ee91736d56a051b783e92322d5f3a4eaeb991
MD5 593be50311ac8b465da9acc544c3b0e1
BLAKE2b-256 de759d9b3540acde58e451597abd1b782c0c6979049f6555e4d9f58442fed3c5

See more details on using hashes here.

File details

Details for the file backchannel_classifier-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for backchannel_classifier-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce371870d60d1eeeefe615a6faff5e080e7953a23c263d7d189d8ee4f19bb4fe
MD5 858b95d8a474af99c6061c757182852f
BLAKE2b-256 ff31f92ab1adcbc6afb82893eab98fc1b9f25d6f0654c018773a8c1650c468a5

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