> For the complete documentation index, see [llms.txt](https://sharinghub.kittenbot.hk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sharinghub.kittenbot.hk/mcu/futureboard/micropython/api15.md).

# 未來板MicroPython編程15：ASR 語音模組

### 導入ASR庫

需要先導入ASR的庫才可以使用ASR 語音模組。

```
from sugar_asr import SugarASR
```

### 15: ASR 語音模組

### 語音模組初始化

```
asr = SugarASR(tx, rx)
```

* tx為模組藍色線，配合Robotbit Edu使用請填”P2”。
* rx為模組綠色線，配合Robotbit Edu使用請填”P12”。

### 語音模組觸發狀態

```
asr.detected()
```

* 聽到任何指令時為true，否則為false。

### 語音模組聽到指令

```
asr.cmdParse()
```

* 返回語音模組所聽到的指令序號，詳細序號請參考以下列表。

![](https://kittenbothk.readthedocs.io/en/latest/_images/asr_codes.png)

### 語音模組語音播報

```
asr.tts_words(1)
```

* 語音播報序號指令，詳細序號請參考以下列表。

![](https://kittenbothk.readthedocs.io/en/latest/_images/tts_codes.png)

### 語音播報數字

```
asr.tts_int(1) #整數
asr.tts_double(1.1) #小數 (最多2個小數位)
```

### 語音播報時間

```
asr.tts_clock(hour, min)
```

* 語音播報時間，hour為小時，min為分鐘。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sharinghub.kittenbot.hk/mcu/futureboard/micropython/api15.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
