aardio 文档

web.edgeTextToSpeech 库模块帮助文档

web 成员列表 #

web.edgeTextToSpeech() #

返回对象:EdgeTextToSpeechObject

web.edgeTextToSpeech(文本,保存文件路径,语音选项) #

文本转语音并存为 MP3 文件。
本人编写此扩展库仅为技术研究目的,其他请依据 Edge 用户协议勿作不当用途

web.edgeTextToSpeech(文本,文件对象,语音选项) #

文本转语音并存为 MP3 文件。
参数 @2 可以是任何提供 write 函数的对象。
例如 fsys.stream 或 fsys.file ,io.file 等对象。

如果不指定文件参数,则调用 fsys.stream 创建内存文件对象,
并在 OnResponseEnd 事件的第 2 个参数中返回 mp3 数据

web.edgeTextToSpeech 成员列表 #

文本转语音。
提前打开控制台可查看 WebSocket 错误信息。

此扩展库仅支持 aardio v40.26 以上版本。

web.edgeTextToSpeech.OnResponseEnd #

web.edgeTextToSpeech.OnResponseEnd = function(text){
    /*一段 pushText 函数发送的文本已合成语音,正在朗读*/
}

web.edgeTextToSpeech.popSpeech() #

朗读文本,使用 web.edgeTextToSpeech.voiceOptions 指定语音合成参数

web.edgeTextToSpeech.pushText() #

将要识别的文本发送到自动识别缓冲区。
可以用定时器调用 popSpeech 函数自动将文本转为语音。
适合用于处理大模型打字式回复的文本,此函数可以自动去重,
并且一句一句的朗读,尽量不在中间断句

web.edgeTextToSpeech.voiceOptions #

web.edgeTextToSpeech.voiceOptions = {    
    name = "zh-CN-XiaoxiaoNeural";  
    lang = "zh-CN";  
    pitch = "+0Hz";   
  rate = "-0%";   
    volume = "+0%";    
}

EdgeTextToSpeechObject 成员列表 #

EdgeTextToSpeechObject.ConnectAsync() #

连接服务器并朗读文本

EdgeTextToSpeechObject.Headers #

EdgeTextToSpeechObject.Headers["/*指定自定义 HTTP 请求头名字,不包含冒号。  
值必须是字符串 或 null。  
值为 null 时可清除之前设置的自定义请求头*/"] = ""

EdgeTextToSpeechObject.IsAlive #

是否连接状态

EdgeTextToSpeechObject.IsSecure #

是否安全连接

EdgeTextToSpeechObject.OnClose #

EdgeTextToSpeechObject.OnClose = function(sender, e){
    /*接口已关闭。  
e.Code 为错误码数值,e.Reason 为表示错误原因的字符串*/
}

EdgeTextToSpeechObject.OnError #

EdgeTextToSpeechObject.OnError = function(sender, e){
    /*"出错了, e.Message 为错误消息,字符串值。  
如果错误为异常,则 e.Exception 为 System.Exception 对象*/

}

EdgeTextToSpeechObject.OnResponseEnd #

EdgeTextToSpeechObject.OnResponseEnd = function(path,text,mp3Data){
    /*文本转语音已完成,path 为语音文件路径,text 为识别的文本。  
如果创建对象时没有指定接收 mp3 的文件或路径,  
mp3Data 则为 mp3 的内存数据*/
}

EdgeTextToSpeechObject.Origin #

Origin 请求头

EdgeTextToSpeechObject.Protocol #

协议

EdgeTextToSpeechObject.ReadyState #

连接状态 web.SocketSharp.WebSocketState 枚举

EdgeTextToSpeechObject.SetProxy #

设置代理服务器

EdgeTextToSpeechObject.SetProxy(url,username,password) #

设置代理服务器,代理地址必须以 "HTTP://" 开始,例如 "HTTP://127.0.0.1:1082"。
参数 @2 指定用户名,参数 @3 指定密码,不需要登录也要指定空字符串

EdgeTextToSpeechObject.Url #

连接 URL,System.Uri 对象

EdgeTextToSpeechObject.WaitTime #

等待时间 System.TimeSpan 对象

EdgeTextToSpeechObject.SslConfiguration 成员列表 #

EdgeTextToSpeechObject.SslConfiguration.EnabledSslProtocols #

设置 SSL 协议版本,默认为 12288/*tls13*/ | 3072/*Tls12*/| 768/*Tls11*/ | 192/*Tls*/

EdgeTextToSpeechObject.voiceOptions 成员列表 #

EdgeTextToSpeechObject.voiceOptions.lang #

调整语言,默认为 "zh-CN";

EdgeTextToSpeechObject.voiceOptions.name #

语音,默认为 "zh-CN-XiaoxiaoNeural";

EdgeTextToSpeechObject.voiceOptions.outputFormat #

输出格式,只能设为 "audio-24khz-48kbitrate-mono-mp3"

EdgeTextToSpeechObject.voiceOptions.pitch #

调整音高,默认为 "+0Hz";

EdgeTextToSpeechObject.voiceOptions.rate #

调整速率,默认为 "-0%";

EdgeTextToSpeechObject.voiceOptions.text #

要朗读的文本

EdgeTextToSpeechObject.voiceOptions.volume #

调整音量,默认为 "+0%";

Markdown 格式