//仿真人语音合成 //Edge WebSocket 大声朗读接口: file://~/example/Media/Audio/edgeTTS.aardio import chrome.edge; var theApp = chrome.edge.app(); import sys.audioVolume; var volumeCtrl = sys.audioVolume(); import dotNet.waveIn; theApp.external = { getVolume = function(){ return volumeCtrl.volume; } setVolume = function(v){ v = tonumber(v) if(volumeCtrl.volume = v) return; volumeCtrl.volume = v; volumeCtrl.mute = !v; } startRecording = function(){ dotNet.waveIn.startLoopback("/edge.wav"); } stopRecording = function(){ dotNet.waveIn.stop(); } openWav = function(){ if(!io.exist("/edge.wav")){ return theApp.msgboxErr("请先录音"); } process.exploreSelect("/edge.wav") } } //因为 /res/ 已设为 theApp.http.documentBase,这里不用再写 "/res/index.aardio" theApp.httpHandler["/index.aardio" ] = function(response,request){ response.write(` Edge 语音合成
`) } //此函数参数指定的回调函数会在网页端准备就绪后执行 theApp.indexReady( function($){ //参数 $ 表示当前连接到 aardio 的网页客户端 theApp.doScript($,` document.getElementById("txt").innerText = "这是测试文本"; `) } ) //可选在调用 start 函数前用 theApp.setPos 或 theApp.center 调整窗口位置 theApp.setPos(20,20,1080,720) /* 正式启动 Edge 进程, 如果文件名为 index.html 或 index.aardio,目录 "/res/" 会自动设为 theApp.http.documentBase。 之后网页访问 "/index.aardio" 会自动转为 "/res/index.aardio" 。 */ theApp.start("/res/index.aardio") //网页中可以调用 aardio.quit() 退出,也可以直接关闭 Edge 窗口退出 win.loopMessage();