Skip to content

Latest commit

 

History

History
86 lines (65 loc) · 2.93 KB

README.md

File metadata and controls

86 lines (65 loc) · 2.93 KB

Vim Piper

A simple wrapper over the Piper text-to-speech system.

Introduction

Vim Piper is a Vim plugin that integrates the Piper text-to-speech system into Vim. It allows you to easily convert text within Vim to speech using Piper.
If you don't care about natural sounding tts, you can use vim-espeak.

Dependency

This plugin depends on the following:

  • piper-tts
  • a piper voice
  • aplay command from alsa-utils package (probably already installed)
  • Vim or Neovim

Getting piper

On Arch Linux, do the following:

yay -S piper-tts-bin piper-voices-en-us # or your language of choice

You may also find piper and it's voices in the repositories of other distros, if not, simply grab the pre-compiled binaries of piper from here, and manually download your desired voices from here.
Once the download is finished, you can refer to the Configuration section of this README to find out out to setup vim-piper.

Installation

Using vim-plug

Add the following to your ~/.vimrc or ~/.config/nvim/init.vim:

Plug 'wolandark/vim-piper'

Then run :PlugInstall in Vim.

Configuration

You can configure the following variables in your ~/.vimrc.

let g:piper_bin = '/path/to/piper'
let g:piper_voice = '/path/to/voice/model.onnx'

The default values are:

let g:piper_bin = '/usr/bin/piper-tts'
let g:piper_voice = '/usr/share/piper-voices/en/en_US/joe/medium/en_US-joe-medium.onnx'

So if you install piper-tts and piper-voices-en-us from AUR, everything will work out of the box.

Functions

The plugin provides the following functions:

  • PassVisualSelection(): Utility function to get the visual selection.
  • SpeakWord(): Speak the word under the cursor.
  • SpeakCurrentLine(): Speak the current line.
  • SpeakCurrentParagraph(): Speak the current paragraph.
  • SpeakVisualSelection(): Speak the visual selection.
  • SpeakCurrentFile(): Speak the current file.

Mappings

The following mappings are defined by default:

  • nnoremap tw :call SpeakWord()
  • nnoremap tc :call SpeakCurrentLine()
  • nnoremap tp :call SpeakCurrentParagraph()
  • nnoremap tf :call SpeakCurrentFile()
  • vnoremap tv :call SpeakVisualSelection()

Demo

SpeakWord()

speakword.mp4

SpeakCurrentLine()

speakcurrentline.mp4

SpeakCurrentParagraph()

speakcurrentparagraph.mp4

SpeakCurrentFile()

speakcurrentfile.mp4

SpeakVisualSelection()

speakvisualselection.mp4

License

Same as Vim.

Enjoy!