Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save siuoly/068f07c45cfa041d0bd4299b9414b727 to your computer and use it in GitHub Desktop.
Save siuoly/068f07c45cfa041d0bd4299b9414b727 to your computer and use it in GitHub Desktop.
WSL vim translate && pronunciation in vim, 在WSL,vim當中翻譯並且發音

prerequist

sudo pip install googletrans==3.1.0a0
sudo pip install gTTS

prepare mpg123

vim command

" pronunce the word on the cursor,  type  'gsp'
nnoremap gsp :!gtts-cli <cword> \| mpg123.exe -q - <cr>

" pronunce the selected sentence
xnoremap gsp :!gtts-cli - \| mpg123.exe -q - <cr>
"  \|        : pipleline symbol, using escape character when using mapping commnad
" gtts-cli - : When read from pipleline, file name is "-"(dash) conventionally.
" mpg123 -q -:  -q means "silently",  - mean :read from stdin.
" <cr>       : mean "Enter" key for key mapping command in vim.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment