ggerganov commited on
Commit
6f8ab0e
·
1 Parent(s): ec60ee3

Create README.md

Browse files
Files changed (1) hide show
  1. examples/whisper.nvim/README.md +76 -0
examples/whisper.nvim/README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # whisper.nvim
2
+
3
+ Speech-to-text in Neovim
4
+
5
+ The transcription is performed on the CPU and no data leaves your computer. Works best on Apple Silicon devices.
6
+
7
+ https://user-images.githubusercontent.com/1991296/198382564-784e9663-2037-4d04-99b8-f39136929b7e.mp4
8
+
9
+ ## Usage
10
+
11
+ - Simply press `Ctrl-G` in `INSERT`, `VISUAL` or `NORMAL` mode and say something
12
+ - When you are done - press `Ctrl-C` to end the transcription and insert the transcribed text under the cursor
13
+
14
+ ## Installation
15
+
16
+ *Note: this is a bit tedious and hacky atm, but I hope it will be improved with time*
17
+
18
+ - Clone this repo and build the `stream` tool:
19
+
20
+ ```
21
+ git clone https://github.com/ggerganov/whisper.cpp
22
+ cd whisper.cpp
23
+ make stream
24
+ ```
25
+
26
+ - Download the `base.en` Whisper model (140 MB):
27
+
28
+ ```
29
+ ./models/download-ggml-model.sh base.en
30
+ ```
31
+
32
+ - Place the [whisper.nvim](whisper.nvim) script somewhere in your PATH and give it execute permissions:
33
+
34
+ ```
35
+ cp examples/whisper.nvim/whisper.nvim ~/bin/
36
+ chmod u+x ~/bin/whisper.nvim
37
+ ```
38
+
39
+ - Fine-tune the script to your preference and machine parameters:
40
+
41
+ ```
42
+ ./stream -t 8 -m models/ggml-base.en.bin --step 350 --length 10000 -f /tmp/whisper.nvim 2> /dev/null
43
+ ```
44
+
45
+ On slower machines, try to increase the `step` parameter.
46
+
47
+ - Add the following shortcuts to your `~/.config/nvim/init.vim`:
48
+
49
+ ```
50
+ inoremap <C-G> <C-O>:!whisper.nvim<CR><C-O>:let @a = system("cat /tmp/whisper.nvim \| tail -n 1 \| xargs -0 \| tr -d '\\n' \| sed -e 's/^[[:space:]]*//'")<CR><C-R>a
51
+ nnoremap <C-G> :!whisper.nvim<CR>:let @a = system("cat /tmp/whisper.nvim \| tail -n 1 \| xargs -0 \| tr -d '\\n' \| sed -e 's/^[[:space:]]*//'")<CR>"ap
52
+ vnoremap <C-G> c<C-O>:!whisper.nvim<CR><C-O>:let @a = system("cat /tmp/whisper.nvim \| tail -n 1 \| xargs -0 \| tr -d '\\n' \| sed -e 's/^[[:space:]]*//'")<CR><C-R>a
53
+ ```
54
+
55
+ You are now ready to use speech-to-text in Neovim!
56
+
57
+ ## TODO
58
+
59
+ There are a lot of ways to improve this idea and I don't have much experience with Vim plugin programming, so contributions are welcome!
60
+
61
+ - [ ] **Wrap this into a plugin**
62
+
63
+ It would be great to make a standalone plugin out of this that can be installed with `vim-plug` or similar
64
+
65
+ - [ ] **Simplify the `init.vim` mappings (maybe factor out the common call into a separate function)**
66
+ - [ ] **Add Copilot/GPT-3 integration**
67
+
68
+ This is probably a very long shot, but I think it will be very cool to have the functionality to select some code and then hit Ctrl-G and say something like:
69
+
70
+ *refactor this using stl containers*
71
+
72
+ or
73
+
74
+ *optimize by sorting the data first*
75
+
76
+ The plugin would then make an appropriate query using the selected text and some context to Copilot or GPT-3 and return the result.