File size: 2,802 Bytes
8c6c70c
 
9cf2f4a
 
 
2d9c975
16781d2
8c6c70c
 
 
9cf2f4a
8c6c70c
 
9cf2f4a
 
2d9c975
9cf2f4a
 
 
 
 
 
2d9c975
9cf2f4a
2d9c975
9cf2f4a
 
 
 
 
2d9c975
 
 
 
 
9cf2f4a
 
 
 
 
 
 
 
 
 
 
2d9c975
9cf2f4a
 
 
 
 
 
2d9c975
 
 
9cf2f4a
2d9c975
 
 
 
 
 
 
 
 
 
 
9cf2f4a
 
 
 
 
 
2d9c975
 
9cf2f4a
 
 
 
54b5848
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: Dinercall Intent Demo
emoji: 🏆
colorFrom: red
colorTo: gray
sdk: gradio
sdk_version: 5.25.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: restaurant reservation intent detector
---

# 🍽️ 餐廳訂位意圖識別系統 (Mandarin Reservation Intent Classifier)

🎙️ 本系統讓使用者可以透過**語音錄音****文字輸入**,自動判斷是否具有「訂位意圖」,是語音助理或自動客服前端的理想元件之一。這個版本基於 **Gradio** 建構,具有簡單直觀的分頁式輸入模式切換(「麥克風」或「文字」)。

---

## 🔍 功能介紹

- 🧠 **語音辨識**:使用 fine-tuned Whisper 模型 [`Jingmiao/whisper-small-zh_tw`](https://huggingface.co/Jingmiao/whisper-small-zh_tw) 將語音轉為繁體中文文字。
- 🤖 **意圖分類**:使用微調的 ALBERT 中文模型或 Qwen 模型判斷輸入是否包含訂位意圖。
- 📱 **支援手機與桌機**:介面具備良好響應性,適用於各類瀏覽器與行動裝置。
- 🔊 **雙重輸入模式**:使用者可在「麥克風」和「文字」兩種模式間切換,以提供語音或手動輸入。

---

## 🚀 使用方式

1. 選擇輸入模式:
   - 「麥克風」:點擊錄音按鈕開始錄音,錄製完成後自動轉文字並判斷意圖。
   - 「文字」:直接在文字框中輸入語句,再點擊「執行辨識」按鈕。
2. 從下拉選單選擇使用的模型(例如 ALBERT-tiny、ALBERT-base 或 Qwen)。
3. 按下「執行辨識」後,系統將顯示轉換後的文字、意圖判斷結果,並以 TTS(語音合成)的方式回應。

---

## 🤗 使用模型

### Whisper 語音辨識:
- [`Jingmiao/whisper-small-zh_tw`](https://huggingface.co/Jingmiao/whisper-small-zh_tw)

### 中文意圖分類模型:
- [`Luigi/albert-tiny-chinese-dinercall-intent`](https://huggingface.co/Luigi/albert-tiny-chinese-dinercall-intent)
- [`Luigi/albert-base-chinese-dinercall-intent`](https://huggingface.co/Luigi/albert-base-chinese-dinercall-intent)
- 或使用 [`Qwen/Qwen2.5-0.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct)(透過 Outlines 整合)

---

## 📦 依賴環境

```txt
llama-cpp-python
gradio>=5.0.0
transformers
torch
soundfile
outlines
numpy>=1.24,<2.0
kokoro
huggingface-hub
jieba
docopt
ordered-set
cn2an
pypinyin
sentencepiece
```

---

## 🛠️ 開發者備註

- 本應用現改為 Gradio App,適合在 Hugging Face Spaces 上部署,並支援 Gradio V5 的最新功能。
- 採用雙重輸入模式(麥克風與文字)讓使用者能靈活切換輸入方式。
- 若需延伸本系統至其他語言或多輪對話,歡迎 fork 本專案進行改造!

---

© 2024 by Luigi. Made with ❤️ using Hugging Face + Gradio.
---