Skip to content

jojoth/S2STEval

Repository files navigation

S2ST Evaluation Project

Speech-to-Speech Translation Evaluation System
ระบบประเมินคุณภาพและ Latency สำหรับ S2ST (En → Th) โดยใช้ BLEU, chrF++, COMET และ BLASER 2.0
ข้อมูล ณ วันที่ 19 พฤษภาคม 2568 (Asia/Bangkok)


📋 Table of Contents


Overview

ระบบนี้ประเมิน S2ST output ใน 2 มิติ:

Script หน้าที่ Metrics
S2ST_QualityEval1.py ประเมินคุณภาพการแปล BLEU, chrF++, COMET, BLASER 2.0
S2ST_LatencyEval.py ประเมิน latency ผ่าน gRPC TTFB, Total latency

Evaluation Standards

  • WMT — มาตรฐาน text-based metrics (BLEU, chrF++, COMET)
  • IWSLT — มาตรฐาน speech translation evaluation
  • Meta FAIR — BLASER 2.0 สำหรับ speech-based scoring

Prerequisites

ก่อนเริ่มต้องมีสิ่งต่อไปนี้:

  • OS: Ubuntu 22.04 / 24.04 หรือ WSL2 บน Windows
  • Python: 3.12 ขึ้นไป
  • IDE: PyCharm (Professional หรือ Community)
  • Disk: ว่างอย่างน้อย 10 GB (สำหรับ COMET + BLASER model)
  • RAM: อย่างน้อย 8 GB
  • Git: ติดตั้งแล้ว

Installation

ขั้นตอนที่ 1 — ตรวจสอบ Python และ pip

python3 --version
# ควรได้ Python 3.12.x ขึ้นไป

pip3 --version
# ถ้าไม่มี pip ให้รัน:
sudo apt install python3-pip -y

ขั้นตอนที่ 2 — สร้าง Virtual Environment ชื่อ blaser

# สร้าง venv
python3 -m venv ~/.venvs/blaser

# Activate venv (ต้องทำทุกครั้งที่เปิด terminal ใหม่)
source ~/.venvs/blaser/bin/activate

# ตรวจสอบ (จะเห็น "(blaser)" หน้า prompt)
which python
# ควรได้: /home/<user>/.venvs/blaser/bin/python

ขั้นตอนที่ 3 — ตั้งค่า PyCharm ให้ใช้ venv นี้

1. File → Settings (Ctrl+Alt+S)
2. Project: S2STEval → Python Interpreter
3. กด gear icon → Add Interpreter → Add Local Interpreter
4. เลือก "Existing" → path: /home/<user>/.venvs/blaser/bin/python
5. กด OK → Apply

ขั้นตอนที่ 4 — ติดตั้ง System Dependencies

sudo apt update
sudo apt install -y \
    build-essential \
    libsndfile1 \
    ffmpeg \
    git

ขั้นตอนที่ 5 — อัปเกรด pip

source ~/.venvs/blaser/bin/activate
pip install --upgrade pip setuptools wheel

ขั้นตอนที่ 6 — ติดตั้ง Text-based Evaluation Libraries

6.1 sacreBLEU (BLEU + chrF++)

pip install sacrebleu
# ตรวจสอบ
python -c "from sacrebleu.metrics import BLEU, CHRF; print('sacrebleu OK')"

📄 อ้างอิง: Post (2018) — ACL Anthology W18-6319


6.2 unbabel-comet (COMET)

pip install unbabel-comet
# ตรวจสอบ
python -c "from comet import download_model; print('comet OK')"

⚠️ ครั้งแรกที่รันโปรแกรม จะ download model ~2 GB อัตโนมัติ
Model ที่ใช้: Unbabel/wmt22-comet-da

📄 อ้างอิง: Rei et al. (2020) — EMNLP 2020


ขั้นตอนที่ 7 — ติดตั้ง Speech-based Evaluation (BLASER 2.0)

7.1 ติดตั้ง stopes (Meta FAIR)

pip install stopes[blaser]

# ถ้า error ให้ลองแบบนี้แทน:
pip install stopes
pip install sonar-space
# ตรวจสอบ
python -c "from stopes.eval.blaser.blaser2 import compute_blaser2; print('BLASER OK')"

# ตรวจสอบ version (ควรได้ 2.2.x ขึ้นไป)
pip show stopes

📄 อ้างอิง: Chen et al. (2023) — arXiv:2212.08486


7.2 ดาวน์โหลด BLASER 2.0 Model

python -c "
from stopes.eval.blaser.blaser2 import download_blaser2_model
download_blaser2_model('blaser_2_0_ref')
print('BLASER model downloaded OK')
"

⚠️ Model จะถูกเก็บใน ~/.cache/blaser/ ขนาดประมาณ 1-2 GB


ขั้นตอนที่ 8 — ติดตั้ง gRPC (สำหรับ Latency Evaluation)

8.1 ติดตั้ง grpcio และ protobuf

pip install grpcio grpcio-tools "protobuf>=6.31.1"
# ตรวจสอบ
python -c "import grpc; print('grpc:', grpc.__version__)"
python -c "import google.protobuf; print('protobuf:', google.protobuf.__version__)"

8.2 Generate pb2 files จาก translator.proto

cd /mnt/c/Pong_Work/Python_Project/S2STEval/
source ~/.venvs/blaser/bin/activate

python -m grpc_tools.protoc \
    --python_out=. \
    --grpc_python_out=. \
    -I. \
    translator/translator.proto
# ตรวจสอบ (ควรเห็นทั้งสองไฟล์)
ls translator_pb2*.py

ขั้นตอนที่ 9 — ตรวจสอบ requirements ทั้งหมด

source ~/.venvs/blaser/bin/activate
pip show sacrebleu unbabel-comet stopes grpcio protobuf

สรุป Libraries ที่ใช้

Library หน้าที่ Version
sacrebleu BLEU + chrF++ scoring latest
unbabel-comet COMET neural scoring latest
stopes BLASER 2.0 speech scoring >= 2.2.1
sonar-space SONAR embeddings (BLASER) latest
grpcio gRPC communication latest
grpcio-tools pb2 file generation latest
protobuf Protocol Buffers runtime >= 6.31.1

Project Structure

S2STEval/
├── S2ST_QualityEval1.py      # ประเมินคุณภาพ (BLEU, chrF++, COMET, BLASER)
├── S2ST_LatencyEval.py       # ประเมิน latency ผ่าน gRPC
├── translator/               # gRPC generated files
│   ├── translator.proto
│   ├── translator_pb2.py
│   └── translator_pb2_grpc.py
├── Text/                     # Text data สำหรับ text-based metrics
│   ├── src.txt               # ประโยคต้นฉบับ (EN)
│   ├── ref1.txt              # ประโยคอ้างอิง (TH, มนุษย์แปล)
│   └── hyp6.txt              # ผลการแปลจากระบบ S2ST
├── sound/                    # Audio data สำหรับ BLASER
│   ├── good/
│   │   ├── src_audio.wav
│   │   ├── ref_audio.wav
│   │   └── tgt_audio.wav
│   ├── partial/
│   └── bad/
├── pairs.tsv                 # Mapping file สำหรับ BLASER
├── requirements.txt
├── .gitignore
└── README.md

Usage

รัน Quality Evaluation

source ~/.venvs/blaser/bin/activate
cd /mnt/c/Pong_Work/Python_Project/S2STEval/

python S2ST_QualityEval1.py

ผลที่ควรได้:

=== ConClude Text-based Metrics ===
- BLEU   : xx.xx
- chrF++ : xx.xx
- COMET  : x.xxxx (Scale 0..1, Near 1 = Good)
Final Score Text-based Metrics=x.xx

======================= Speech-based Evaluation (BLASER) =======================
Mean (unsupervised cosine) [≈0..1]: x.xxxx
Mean (supervised 1..5)            : x.xxxx

รัน Latency Evaluation

source ~/.venvs/blaser/bin/activate
cd /mnt/c/Pong_Work/Python_Project/S2STEval/

python S2ST_LatencyEval.py sound/good/src_audio.wav

Troubleshooting

ปัญหา สาเหตุ วิธีแก้
protobuf VersionError gencode/runtime version ไม่ตรงกัน pip install "protobuf>=6.31.1"
COMET รันช้ามาก ไม่มี GPU → ใช้ CPU ปกติครับ รอได้ (gpus=0 ในโค้ด)
stopes import error version เก่าเกิน pip install stopes --upgrade
BLASER model ไม่พบ ยังไม่ได้ download รันขั้นตอนที่ 7.2 ใหม่
sound/ หรือ Text/ ไม่พบ รันจาก path ผิด cd S2STEval/ ก่อนรันเสมอ
Author identity unknown (git) ยังไม่ตั้งค่า git user git config --global user.email "email" และ git config --global user.name "name"

References

Metric Paper Link
BLEU / sacreBLEU Post (2018), WMT ACL W18-6319
chrF++ Popović (2017), WMT ACL W17-4770
COMET Rei et al. (2020), EMNLP ACL 2020.emnlp-main.213
BLASER 2.0 Chen et al. (2023), Meta FAIR arXiv:2212.08486
MultiMed-ST Dataset Le-Duc et al. (2025), EMNLP arXiv:2504.03546
BLEU Meets COMET Glushkova et al. (2023), EAMT arXiv:2305.19144

S2ST Evaluation Project — En → Th | Phase 1

About

S2ST Evaluation System - Quality & Latency

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages