thai-voice-command
Thai voice commands made simple. Give it text from any speech recognizer (sherpa-onnx, Whisper, Google, the browser's Web Speech API) and it will:
- detect a wake phrase even when the ASR misspells it (
จาร์วิส,จาวิส,จาวิทย์…) - route the command to your function, ignoring spaces and polite particles (
ครับ,ค่ะ) - pull out arguments (
ค้นหา แมว→"แมว") - use fuzzy matching safely: unclear speech is ignored, never guessed
- cut microphone audio into utterances with a tiny pure-Python VAD
No required dependencies. Python 3.9+.
Extracted from JARVIS, a Thai desktop voice assistant, where real ASR mis-hearings were collected and tuned.
Install
pip install thai-voice-command
Quick start
from thai_voice_command import Router, WakeWord, JARVIS_ALIASES
router = Router(wake=WakeWord(JARVIS_ALIASES))
@router.command(phrases=["เปิดยูทูบ", "เปิด youtube"])
def youtube(match):
return "opening YouTube"
@router.command(prefixes=["ค้นหา"])
def search(match):
return f"searching for {match.arg}"
router.handle("จาร์วิส เปิด ยูทูบ ครับ") # 'opening YouTube'
router.handle("จาวิทย์ ค้นหา Roblox") # 'searching for Roblox'
router.handle("เปิดยูทูบ") # None (no wake phrase)
router.handle("จาร์วิส ทำกับข้าว") # None (unknown, ignored)
How matching works
Checked in this order; the first hit wins.
| Step | Example rule | Matches |
|---|---|---|
| Exact phrase | phrases=["เปิดโน้ตแพด"] |
เปิด โน้ตแพด ครับ |
| Prefix + argument | prefixes=["ค้นหา"] |
ค้นหา แมว → arg="แมว" |
| Keyword groups | keywords=[["เวลา","กี่โมง"]] |
ตอนนี้กี่โมง |
| Fuzzy phrase | automatic | เปิดยูทูป → เปิดยูทูบ |
Fuzzy matching accepts a command only when its score is at least
min_score (default 0.78) and beats every other command by
min_margin (default 0.065). So เปิดโน๊ตแพด is rejected when both
"open Notepad" and "close Notepad" exist: the two scores (0.909 vs 0.857)
are too close to be sure. For an assistant that launches programs, doing
nothing is safer than doing the wrong thing.
Microphone
Segmenter turns 16-bit mono PCM blocks into whole utterances:
from thai_voice_command import Segmenter
seg = Segmenter(sample_rate=16000, block_samples=1280)
for block in mic_blocks:
utterance = seg.feed(block)
if utterance:
text = my_asr(utterance)
router.handle(text)
See examples/microphone_sherpa.py for a full offline Thai example.
Contributing
New wake-word aliases, Thai command phrases, and bug reports are very welcome. See CONTRIBUTING.md. Thai or English is fine.
License
MIT
Metadata
Release files for thai-voice-command 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| thai_voice_command-0.1.0.tar.gz | 11.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thai_voice_command-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / thai_voice_command-0.1.0.tar.gz
| Download URL | thai_voice_command-0.1.0.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e080d887333f5d7b374700e7c15eb16f6e0fbbe80eb51e1500cc8e72e56c9997
|
|
BLAKE2b-256 checksum How to use checksums |
896f690a3f442b71e7ec64d9878fe75fd3019e536308d0cf17bcdcbabf5e8074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / thai_voice_command-0.1.0-py3-none-any.whl
| Download URL | thai_voice_command-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bac86721ba5db30b8cf370bea4b62f4e6b19e44216e0dd434ea8979d7d76f62
|
|
BLAKE2b-256 checksum How to use checksums |
bdca7ac832fc51e57cedea77bbd0f7d6f255300037f0e291d643e994e7787b37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency log