# 类: VoiceMessage

[(返回目录)](/api.md)

**继承自:** [Message](/api/message.md)

RainyBot的语音消息类，其实例记录了与一个语音消息相关的各类数据

## 方法

* static [VoiceMessage](/api/voicemessage.md) **init\_id (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_id **)**

基于指定的语音ID来手动构造一个VoiceMessage类的实例

***

* static [VoiceMessage](/api/voicemessage.md) **init\_url (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_url **)**

基于指定的音频URL链接来手动构造一个VoiceMessage类的实例

***

* static [VoiceMessage](/api/voicemessage.md) **init\_path (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_path **)**

基于指定的本地音频路径来手动构造一个VoiceMessage类的实例

***

* static [VoiceMessage](/api/voicemessage.md) **init\_base64 (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_base64 **)**

基于指定的音频Base64编码来手动构造一个VoiceMessage类的实例

***

* static [VoiceMessage](/api/voicemessage.md) **init\_meta (** [Dictionary](https://docs.godotengine.org/en/latest/classes/class_dictionary.html) dic **)**

通过机器人协议后端的元数据字典构造一个此类的实例，仅当你知道自己在做什么时才使用

***

* [String](https://docs.godotengine.org/en/latest/classes/class_string.html) **get\_voice\_id ( )**

获取此实例对应的语音的ID

***

* void **set\_voice\_id (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_id **)**

设置此实例对应的语音的ID

***

* [String](https://docs.godotengine.org/en/latest/classes/class_string.html) **get\_voice\_url ( )**

获取此实例对应的音频的URL链接

***

* void **set\_voice\_url (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_url **)**

设置此实例对应的音频的URL链接

***

* [String](https://docs.godotengine.org/en/latest/classes/class_string.html) **get\_voice\_path ( )**

获取此实例对应的音频的本地路径

***

* void **set\_voice\_path (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_path **)**

设置此实例对应的音频的本地路径

***

* [String](https://docs.godotengine.org/en/latest/classes/class_string.html) **get\_voice\_base64 ( )**

获取此实例对应的音频的Base64编码

***

* void **set\_voice\_base64 (** [String](https://docs.godotengine.org/en/latest/classes/class_string.html) voice\_base64 **)**

设置此实例对应的音频的Base64编码

***

* [int](https://docs.godotengine.org/en/latest/classes/class_int.html) **get\_voice\_length ( )**

获取此示例对应的语音的长度(以秒为单位)

***

* [String](https://docs.godotengine.org/en/latest/classes/class_string.html) **get\_as\_text ( )**

将此实例获取为字符串的形式

***


---

# 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://docs.rainybot.dev/api/voicemessage.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.
