https://github.com/cskeeters/kokoro.nvim
Neovim plugin to read selected text with Kokoro.
https://github.com/cskeeters/kokoro.nvim
Last synced: about 1 month ago
JSON representation
Neovim plugin to read selected text with Kokoro.
- Host: GitHub
- URL: https://github.com/cskeeters/kokoro.nvim
- Owner: cskeeters
- License: mit
- Created: 2025-03-13T21:39:18.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2025-03-13T23:14:55.000Z (about 1 month ago)
- Last Synced: 2025-03-13T23:26:00.257Z (about 1 month ago)
- Language: Lua
- Size: 336 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-neovim-pluginlist - cskeeters/kokoro.nvim - commit/cskeeters/kokoro.nvim)  (New features / TTS (text-to-speech))
README
This plugin can can help people check text by listening to [Kokoro](https://huggingface.co/hexgrad/Kokoro-82M) read it.
* Breaks paragraphs into sentances and renders *two* at a time asynchronously. Audio typically has a 1-2 second start delay, but is smooth after that.While playing with it, I made it so that it can read books ok too.
* Quoted text will be read in another voice.
* Detects the gender of the speaker and use the appropriate gendered voice.
* Tracks gender used in paragraphs so that paragraphs with quoted text only will use the gender from two paragraphs below to support common back and forth dialog.# Demonstration
A demonstration can be found at .
# Installation
This plugin requires the luarock `lrexlib-pcre`. Use `--lua-version=5.1` to install for neovim.
```sh
luarocks install lrexlib-pcre --lua-version=5.1
```To install with [lazy.nvim](https://github.com/folke/lazy.nvim), You need something like this:
```lua
{
'cskeeters/kokoro.nvim',
lazy = false,
config = function()
-- Verify installation of lrexlib-pcre
local ok, rex = pcall(require, "rex_pcre")
if not ok then
print("Failed to load lrexlib-pcre: " .. rex)
print("Install with:")
print(" luarocks install lrexlib-pcre --lua-version=5.1")
endrequire 'kokoro'.setup({
-- Setting debug to true will route tinymist's stderr to :messages
debug = false,
path = os.getenv("HOME")..'/working/kokoro-tts',
player = "afplay",conda_env = "kokoro",
load_voices = true,
voice = "af_aoede",
})-- NOTE: will prevent range from passing into the function correctly
vim.keymap.set({'v'}, 'gk', ":Kokoro", { noremap=true, silent=true, desc="Read selected text with Kokoro" })
vim.keymap.set({'n'}, 'gk', ":Kokoro", { noremap=true, silent=true, desc="Read current line with Kokoro" })
vim.keymap.set({'n'}, 'gK', ":KokoroStop", { noremap=true, silent=true, desc="Stop playing audio from Kokoro" })
vim.keymap.set({'n'}, 'gkv', ":KokoroChooseVoice", { noremap=true, silent=true, desc="Choose voice for Kokoro" })
vim.keymap.set({'n'}, 'gks', ":KokoroChooseSpeed", { noremap=true, silent=true, desc="Choose speed for Kokoro" })
end
}
```## Setup Options
```lua
{
-- Kokoro Runtime
path = nil,
conda_env = nil,
player = "afplay",-- Plugin Options
debug = false,
workers = 2,
load_voices = true,
word_threshold = 15,-- Kokoro options
voice = "af_aoede",
speed = 1.0,
male_quote_voice="bm_lewis",
female_quote_voice="bf_alice",
}
```# Commands
| Command | Mode | Action |
|----------------------|------|---------------------------------|
| `:Kokoro` | n | Reads the line under the cursor |
| `:Kokoro` | v/V | Reads the selected text. |
| `:KokoroStop` | n | Stops reading immediately |
| `:KokoroChooseVoice` | n | Choose a voice |
| `:KokoroChooseSpeed` | n | Choose a reading speed |