diff --git a/README.md b/README.md index 76e15f7..5223f0b 100644 --- a/README.md +++ b/README.md @@ -104,11 +104,13 @@ use { > 后续会增加 `healthcheck` 进行检查 - **`auto_play`** 使用步骤: + > linux 只需要安装`festival` + > sudo apt-get install festival festvox-kallpc16k + + > 其他操作系统 - 需要确保安装了`nodejs` - 进入插件的`tts`目录运行`npm install` > 如果`install.sh`运行正常则自动安装,如果安装失败,请尝试手动安装 - - linux 用户需要额外安装以下依赖: - > sudo apt-get install festival festvox-kallpc16k ## 配置 ```lua diff --git a/install.sh b/install.sh index 991d623..41ebbf9 100755 --- a/install.sh +++ b/install.sh @@ -14,5 +14,12 @@ wget https://github.com/skywind3000/ECDICT-ultimate/releases/download/1.0.0/ecdi unzip /tmp/dict.zip -d $HOME/.vim/dict + rm -rf /tmp/dict.zip -cd ./tts/ && npm install + + +uNames=`uname -s` +osName=${uNames: 0: 4} +if [ "$osName" != "Linux" ];then + cd ./tts/ && npm install +fi diff --git a/lua/Trans/view/hover.lua b/lua/Trans/view/hover.lua index 253ff7c..0b6efe0 100644 --- a/lua/Trans/view/hover.lua +++ b/lua/Trans/view/hover.lua @@ -256,8 +256,12 @@ action = { end, play = function() - local file = debug.getinfo(1, "S").source:sub(2):match('(.*)lua/') .. 'tts/say.js' - vim.fn.jobstart('node ' .. file .. ' ' .. _word) + if vim.fn.has('linux') == 1 then + vim.fn.jobstart('echo ' .. _word .. ' | festival --tts') + else + local file = debug.getinfo(1, "S").source:sub(2):match('(.*)lua/') .. 'tts/say.js' + vim.fn.jobstart('node ' .. file .. ' ' .. _word) + end end, }