โปรเจคนี้คือ เว็บแอป Flashcard สำหรับฝึกคำศัพท์ภาษาอังกฤษ–ไทย พัฒนาโดยใช้ Angular (Standalone Component) และใช้ Google Sheets เป็นคลังคำศัพท์ ผ่าน Google Apps Script (Web API) พร้อมระบบเสียงอ่าน (Speech Synthesis)
- 📇 แสดงคำศัพท์แบบ Flashcard (Flip Card)
- 🔊 อ่านเสียงคำศัพท์ภาษาอังกฤษด้วย Web Speech API
- ⏳ ปรับความเร็วเสียงอ่านได้
- 🔀 สุ่มลำดับคำศัพท์ (Shuffle)
- ⬅️➡️ ปุ่ม Previous / Next พร้อม animation
- ☁️ ดึงข้อมูลคำศัพท์จาก Google Sheets แบบ real-time
- 🧩 ใช้ Angular Standalone Component (ไม่ใช้ NgModule)
- Frontend: Angular (Standalone, Angular 15+)
- Backend / API: Google Apps Script (Web App)
- Database: Google Sheets
- Speech: Web Speech API (SpeechSynthesis)
สร้าง Google Sheet ที่มีอย่างน้อย 2 คอลัมน์:
| Column A (Word) | Column B (Translation) |
|---|---|
| Hello | สวัสดี |
| Government | รัฐบาล |
| Equality | ความเท่าเทียม |
แถวแรกสามารถเป็น header ได้ (ระบบจะข้ามให้)
function doGet() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
const data = sheet.getDataRange().getValues();
data.shift(); // remove header
return ContentService.createTextOutput(JSON.stringify(data)).setMimeType(
ContentService.MimeType.JSON
);
}- Extensions → Apps Script
- Deploy → New deployment
- Type: Web app
- Execute as: Me
- Who has access: Anyone
- Copy URL ไปใช้ใน Angular
import { provideHttpClient } from '@angular/common/http';
export const appConfig = {
providers: [provideHttpClient()],
};@Component({
selector: 'app-word-card-page',
standalone: true,
imports: [CommonModule],
templateUrl: './word-card-page.html',
styleUrl: './word-card-page.css'
})ngOnInit() {
this.http.get<[string, string][]>(API_URL)
.subscribe(data => {
this.word = this.shuffle([...data]);
this.wordIndex = 0;
});
}opensound() {
const utterance = new SpeechSynthesisUtterance(
this.word[this.wordIndex][0]
);
utterance.lang = 'en-US';
utterance.rate = 0.6; // ความเร็วเสียง
utterance.pitch = 1;
speechSynthesis.cancel();
speechSynthesis.speak(utterance);
}- การ์ดจะ พลิกกลับด้านหน้า ก่อน
- รอ animation (0.8s)
- จากนั้นจึงเปลี่ยนคำศัพท์
if (this.isFlipped) {
this.isFlipped = false;
setTimeout(() => this.moveNext(), 800);
}npm install
ng serveเปิดเบราว์เซอร์ที่:
http://localhost:4200
- 🎚️ Slider ปรับความเร็วเสียง
- 📱 Responsive สำหรับมือถือ
- 🧠 Spaced Repetition (แบบ Anki)
- 💾 Offline Cache (LocalStorage)
- 🗂️ แยกคำศัพท์ตามหมวด / Sheet
MIT License
- Angular Team
- Google Apps Script
- Web Speech API
📌 โปรเจคนี้เหมาะสำหรับผู้ที่ต้องการฝึกภาษา หรือเป็นตัวอย่างการเชื่อม Angular + Google Sheets แบบง่ายและใช้งานจริง