# 音频开发

在RayNeo眼镜上进行音频业务的开发，实现步骤与一般的android平台音频应用开发类似，如果需要调用MIC进行声音的收录，RayNeo眼镜上封装特有的MIC收音模式，在X2跟X3上略有不同：

#### X2支持的收音模式：

每个apk在调用mic的时候，去设置状态通知audioHAL; AudioManager.setparameter("audio\_source=xxxx")；

| 模式                   | 描述                         | 示例                                                    |
| -------------------- | -------------------------- | ----------------------------------------------------- |
| **audio record:**    | **暂未配置**                   | setParameters("audio\_source\_record=sound")          |
| **camera record:**   | **调用镜腿2颗mic，声音全收进来，无降噪算法** | setParameters("audio\_source\_record=camcorder")      |
| **translation:**     | **调用3颗麦克风，不收佩戴者声音，收外部声音**  | setParameters("audio\_source\_record=translation")    |
| **voice assistant:** | **调用镜腿2颗mic，主要收佩戴者声音**     | setParameters("audio\_source\_record=voiceassistant") |

**为了确保各个应用都有自己的mic组合，请在退出record的时候，也设置下**<mark style="color:$danger;">**setParameters("audio\_source\_record=off");**</mark>

#### X3支持的收音模式：

| 模式                   | 前置条件(AudioRecord)                                                                         | setParameters                                           | 描述                                          |
| -------------------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------- |
| OFF                  | 退出录音                                                                                      | audioManager.setParameters("audio\_source\_record=off") | apk退出时记得释放麦克风，退出record的时候需要设置               |
| RECORD\_TRANSLATION  | <p>device.id == SPEAKER\_MIC ;CHANNEL\_IN\_MONO;<br>送翻译引擎的采样率一般设置16k;</p>                 | ExampleRecordTranslation.java                           | 调用前麦克风，录制周围人声，适合会议记录/现场翻译                   |
| CAMCORDER            | <p>device.id == SPEAKER\_MIC;<br>CHANNEL\_IN\_STEREO;<br>采样率根据需要设定，最高不超出48kHz;</p>        | ExampleRecordCamcorder.java                             | 左右镜腿麦克风，立体声录音，全向收音，适合录像场景使用                 |
| VOICE\_RECOGNITION   | <p>device.id == SPEAKER\_MIC;<br>CHANNEL\_IN\_MONO;<br>识别引擎一般要求Sample rate为16kHz，单通道;</p> | ExampleRecordRecognition.java                           | 调用三颗麦克风，只收佩戴者声音，送识别引擎识别，不考虑音质，适合于语音助手，导航场景等 |
| VOICE\_COMMUNICATION | device.id == SPEAKER\_MIC                                                                 | ExampleRecordCommunication.java                         | 调用前麦和右方麦克风，只收佩戴者的声音，适用于网络通话、网络会议等           |

{% file src="/files/ktPdikFZ3gG8gkAMATse" %}

{% file src="/files/vfjBGdaB6pOvG5OUmz7J" %}

{% file src="/files/3kdo7mnmVHDXc208nBeY" %}

{% file src="/files/q9jljpj3kBC0wl0XrQ5j" %}


---

# Agent Instructions: 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:

```
GET https://rayneo.gitbook.io/rayneo-devdoc/x-xi-lie/android-kai-fa/neng-li-jie-shao/yin-pin-kai-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
