# web.edgeTextToSpeech 库模块帮助文档

## web 成员列表 <a id="web" href="#web">&#x23;</a>

### web.edgeTextToSpeech() <a id="web.edgeTextToSpeech" href="#web.edgeTextToSpeech">&#x23;</a>
[返回对象:EdgeTextToSpeechObject](#EdgeTextToSpeechObject)

[返回对象:EdgeTextToSpeechObject](#EdgeTextToSpeechObject)

### web.edgeTextToSpeech(文本,保存文件路径,语音选项) <a id="web.edgeTextToSpeech" href="#web.edgeTextToSpeech">&#x23;</a>
文本转语音并存为 MP3 文件。  
本人编写此扩展库仅为技术研究目的，其他请依据 Edge 用户协议勿作不当用途

文本转语音并存为 MP3 文件。  
本人编写此扩展库仅为技术研究目的，其他请依据 Edge 用户协议勿作不当用途

### web.edgeTextToSpeech(文本,文件对象,语音选项) <a id="web.edgeTextToSpeech" href="#web.edgeTextToSpeech">&#x23;</a>
文本转语音并存为 MP3 文件。  
参数 @2 可以是任何提供 write 函数的对象。  
例如 fsys.stream 或 fsys.file ，io.file 等对象。  

如果不指定文件参数，则调用 fsys.stream 创建内存文件对象，  
并在 OnResponseEnd 事件的第 2 个参数中返回 mp3 数据

文本转语音并存为 MP3 文件。  
参数 @2 可以是任何提供 write 函数的对象。  
例如 fsys.stream 或 fsys.file ，io.file 等对象。  

如果不指定文件参数，则调用 fsys.stream 创建内存文件对象，  
并在 OnResponseEnd 事件的第 2 个参数中返回 mp3 数据

## web.edgeTextToSpeech 成员列表 <a id="web.edgeTextToSpeech" href="#web.edgeTextToSpeech">&#x23;</a>

文本转语音。  
提前打开控制台可查看 WebSocket 错误信息。  

此扩展库仅支持 aardio v40.26 以上版本。

文本转语音。  
提前打开控制台可查看 WebSocket 错误信息。  

此扩展库仅支持 aardio v40.26 以上版本。

### web.edgeTextToSpeech.OnResponseEnd <a id="web.edgeTextToSpeech.OnResponseEnd" href="#web.edgeTextToSpeech.OnResponseEnd">&#x23;</a>

```aardio
web.edgeTextToSpeech.OnResponseEnd = function(text){
	/*一段 pushText 函数发送的文本已合成语音，正在朗读*/
}
```

```aardio
web.edgeTextToSpeech.OnResponseEnd = function(text){
	/*一段 pushText 函数发送的文本已合成语音，正在朗读*/
}
```

### web.edgeTextToSpeech.popSpeech() <a id="web.edgeTextToSpeech.popSpeech" href="#web.edgeTextToSpeech.popSpeech">&#x23;</a>
朗读文本，使用 web.edgeTextToSpeech.voiceOptions 指定语音合成参数

朗读文本，使用 web.edgeTextToSpeech.voiceOptions 指定语音合成参数

### web.edgeTextToSpeech.pushText() <a id="web.edgeTextToSpeech.pushText" href="#web.edgeTextToSpeech.pushText">&#x23;</a>
将要识别的文本发送到自动识别缓冲区。  
可以用定时器调用 popSpeech 函数自动将文本转为语音。  
适合用于处理大模型打字式回复的文本，此函数可以自动去重，  
并且一句一句的朗读，尽量不在中间断句

将要识别的文本发送到自动识别缓冲区。  
可以用定时器调用 popSpeech 函数自动将文本转为语音。  
适合用于处理大模型打字式回复的文本，此函数可以自动去重，  
并且一句一句的朗读，尽量不在中间断句

### web.edgeTextToSpeech.voiceOptions <a id="web.edgeTextToSpeech.voiceOptions" href="#web.edgeTextToSpeech.voiceOptions">&#x23;</a>

```aardio
web.edgeTextToSpeech.voiceOptions = {    
	name = "zh-CN-XiaoxiaoNeural";  
	lang = "zh-CN";  
	pitch = "+0Hz";   
  rate = "-0%";   
	volume = "+0%";    
}
```

```aardio
web.edgeTextToSpeech.voiceOptions = {    
	name = "zh-CN-XiaoxiaoNeural";  
	lang = "zh-CN";  
	pitch = "+0Hz";   
  rate = "-0%";   
	volume = "+0%";    
}
```

## EdgeTextToSpeechObject 成员列表 <a id="EdgeTextToSpeechObject" href="#EdgeTextToSpeechObject">&#x23;</a>

### EdgeTextToSpeechObject.ConnectAsync() <a id="EdgeTextToSpeechObject.ConnectAsync" href="#EdgeTextToSpeechObject.ConnectAsync">&#x23;</a>
连接服务器并朗读文本

连接服务器并朗读文本

### EdgeTextToSpeechObject.Headers <a id="EdgeTextToSpeechObject.Headers" href="#EdgeTextToSpeechObject.Headers">&#x23;</a>

```aardio
EdgeTextToSpeechObject.Headers["/*指定自定义 HTTP 请求头名字，不包含冒号。  
值必须是字符串 或 null。  
值为 null 时可清除之前设置的自定义请求头*/"] = ""
```

```aardio
EdgeTextToSpeechObject.Headers["/*指定自定义 HTTP 请求头名字，不包含冒号。  
值必须是字符串 或 null。  
值为 null 时可清除之前设置的自定义请求头*/"] = ""
```

### EdgeTextToSpeechObject.IsAlive <a id="EdgeTextToSpeechObject.IsAlive" href="#EdgeTextToSpeechObject.IsAlive">&#x23;</a>
是否连接状态

是否连接状态

### EdgeTextToSpeechObject.IsSecure <a id="EdgeTextToSpeechObject.IsSecure" href="#EdgeTextToSpeechObject.IsSecure">&#x23;</a>
是否安全连接

是否安全连接

### EdgeTextToSpeechObject.OnClose <a id="EdgeTextToSpeechObject.OnClose" href="#EdgeTextToSpeechObject.OnClose">&#x23;</a>

```aardio
EdgeTextToSpeechObject.OnClose = function(sender, e){
	/*接口已关闭。  
e.Code 为错误码数值，e.Reason 为表示错误原因的字符串*/
}
```

```aardio
EdgeTextToSpeechObject.OnClose = function(sender, e){
	/*接口已关闭。  
e.Code 为错误码数值，e.Reason 为表示错误原因的字符串*/
}
```

### EdgeTextToSpeechObject.OnError <a id="EdgeTextToSpeechObject.OnError" href="#EdgeTextToSpeechObject.OnError">&#x23;</a>

```aardio
EdgeTextToSpeechObject.OnError = function(sender, e){
	/*"出错了, e.Message 为错误消息，字符串值。  
如果错误为异常，则 e.Exception 为 System.Exception 对象*/

}
```

```aardio
EdgeTextToSpeechObject.OnError = function(sender, e){
	/*"出错了, e.Message 为错误消息，字符串值。  
如果错误为异常，则 e.Exception 为 System.Exception 对象*/

}
```

### EdgeTextToSpeechObject.OnResponseEnd <a id="EdgeTextToSpeechObject.OnResponseEnd" href="#EdgeTextToSpeechObject.OnResponseEnd">&#x23;</a>

```aardio
EdgeTextToSpeechObject.OnResponseEnd = function(path,text,mp3Data){
	/*文本转语音已完成，path 为语音文件路径，text 为识别的文本。  
如果创建对象时没有指定接收 mp3 的文件或路径，  
mp3Data 则为 mp3 的内存数据*/
}
```

```aardio
EdgeTextToSpeechObject.OnResponseEnd = function(path,text,mp3Data){
	/*文本转语音已完成，path 为语音文件路径，text 为识别的文本。  
如果创建对象时没有指定接收 mp3 的文件或路径，  
mp3Data 则为 mp3 的内存数据*/
}
```

### EdgeTextToSpeechObject.Origin <a id="EdgeTextToSpeechObject.Origin" href="#EdgeTextToSpeechObject.Origin">&#x23;</a>
Origin 请求头

Origin 请求头

### EdgeTextToSpeechObject.Protocol <a id="EdgeTextToSpeechObject.Protocol" href="#EdgeTextToSpeechObject.Protocol">&#x23;</a>
协议

协议

### EdgeTextToSpeechObject.ReadyState <a id="EdgeTextToSpeechObject.ReadyState" href="#EdgeTextToSpeechObject.ReadyState">&#x23;</a>
连接状态 web.SocketSharp.WebSocketState 枚举

连接状态 web.SocketSharp.WebSocketState 枚举

### EdgeTextToSpeechObject.SetProxy <a id="EdgeTextToSpeechObject.SetProxy" href="#EdgeTextToSpeechObject.SetProxy">&#x23;</a>
设置代理服务器

设置代理服务器

### EdgeTextToSpeechObject.SetProxy(url,username,password) <a id="EdgeTextToSpeechObject.SetProxy" href="#EdgeTextToSpeechObject.SetProxy">&#x23;</a>
设置代理服务器，代理地址必须以 "HTTP://" 开始，例如 "HTTP://127.0.0.1:1082"。  
参数 @2 指定用户名，参数 @3 指定密码，不需要登录也要指定空字符串

设置代理服务器，代理地址必须以 "HTTP://" 开始，例如 "HTTP://127.0.0.1:1082"。  
参数 @2 指定用户名，参数 @3 指定密码，不需要登录也要指定空字符串

### EdgeTextToSpeechObject.Url <a id="EdgeTextToSpeechObject.Url" href="#EdgeTextToSpeechObject.Url">&#x23;</a>
连接 URL，System.Uri 对象

连接 URL，System.Uri 对象

### EdgeTextToSpeechObject.WaitTime <a id="EdgeTextToSpeechObject.WaitTime" href="#EdgeTextToSpeechObject.WaitTime">&#x23;</a>
等待时间 System.TimeSpan 对象

等待时间 System.TimeSpan 对象

## EdgeTextToSpeechObject.SslConfiguration 成员列表 <a id="EdgeTextToSpeechObject.SslConfiguration" href="#EdgeTextToSpeechObject.SslConfiguration">&#x23;</a>

### EdgeTextToSpeechObject.SslConfiguration.EnabledSslProtocols <a id="EdgeTextToSpeechObject.SslConfiguration.EnabledSslProtocols" href="#EdgeTextToSpeechObject.SslConfiguration.EnabledSslProtocols">&#x23;</a>
设置 SSL 协议版本，默认为 12288/*tls13*/ | 3072/*Tls12*/| 768/*Tls11*/ | 192/*Tls*/

设置 SSL 协议版本，默认为 12288/*tls13*/ | 3072/*Tls12*/| 768/*Tls11*/ | 192/*Tls*/

## EdgeTextToSpeechObject.voiceOptions 成员列表 <a id="EdgeTextToSpeechObject.voiceOptions" href="#EdgeTextToSpeechObject.voiceOptions">&#x23;</a>

### EdgeTextToSpeechObject.voiceOptions.lang <a id="EdgeTextToSpeechObject.voiceOptions.lang" href="#EdgeTextToSpeechObject.voiceOptions.lang">&#x23;</a>
调整语言，默认为 "zh-CN";

调整语言，默认为 "zh-CN";

### EdgeTextToSpeechObject.voiceOptions.name <a id="EdgeTextToSpeechObject.voiceOptions.name" href="#EdgeTextToSpeechObject.voiceOptions.name">&#x23;</a>
语音，默认为 "zh-CN-XiaoxiaoNeural";

语音，默认为 "zh-CN-XiaoxiaoNeural";

### EdgeTextToSpeechObject.voiceOptions.outputFormat <a id="EdgeTextToSpeechObject.voiceOptions.outputFormat" href="#EdgeTextToSpeechObject.voiceOptions.outputFormat">&#x23;</a>
输出格式，只能设为 "audio-24khz-48kbitrate-mono-mp3"

输出格式，只能设为 "audio-24khz-48kbitrate-mono-mp3"

### EdgeTextToSpeechObject.voiceOptions.pitch <a id="EdgeTextToSpeechObject.voiceOptions.pitch" href="#EdgeTextToSpeechObject.voiceOptions.pitch">&#x23;</a>
调整音高，默认为 "+0Hz";

调整音高，默认为 "+0Hz";

### EdgeTextToSpeechObject.voiceOptions.rate <a id="EdgeTextToSpeechObject.voiceOptions.rate" href="#EdgeTextToSpeechObject.voiceOptions.rate">&#x23;</a>
调整速率，默认为 "-0%";

调整速率，默认为 "-0%";

### EdgeTextToSpeechObject.voiceOptions.text <a id="EdgeTextToSpeechObject.voiceOptions.text" href="#EdgeTextToSpeechObject.voiceOptions.text">&#x23;</a>
要朗读的文本

要朗读的文本

### EdgeTextToSpeechObject.voiceOptions.volume <a id="EdgeTextToSpeechObject.voiceOptions.volume" href="#EdgeTextToSpeechObject.voiceOptions.volume">&#x23;</a>
调整音量，默认为 "+0%";

调整音量，默认为 "+0%";
