Skip to content

Commit 0362efe

Browse files
authored
Merge branch 'main' into signature_cleanup
2 parents 90f61c7 + a55dbda commit 0362efe

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 1
6+
tab_width = 4
7+
end_of_line = lf
8+
insert_final_newline = true
9+
charset = utf-8
10+

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,15 @@ Provides custom context per repository:
311311

312312
## Speech commands
313313

314-
#### `:GpWhisper` <!-- {doc=:GpWhisper} -->
314+
#### `:GpWhisper` {lang?} <!-- {doc=:GpWhisper} -->
315315

316316
Transcription replaces the current line, visual selection or range in the current buffer. Use your mouth to ask a question in a chat buffer instead of writing it by hand, dictate some comments for the code, notes or even your next novel..
317317

318318
For the rest of the whisper commands, the transcription is used as an editable prompt for the equivalent non whisper command - `GpWhisperRewrite` dictates instructions for `GpRewrite` etc.
319319

320+
You can override the default language by setting {lang} with the 2 letter
321+
shortname of your language (e.g. "en" for English, "fr" for French etc).
322+
320323
#### `:GpWhisperRewrite` <!-- {doc=:GpWhisperRewrite} -->
321324

322325
Similar to `:GpRewrite`, but the prompt instruction dialog uses transcribed spoken instructions.

doc/gp.nvim.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*gp.nvim.txt* For NVIM v0.8.0 Last change: 2024 July 16
1+
*gp.nvim.txt* For NVIM v0.8.0 Last change: 2024 July 17
22

33
==============================================================================
44
Table of Contents *gp.nvim-table-of-contents*
@@ -252,7 +252,7 @@ options might get deprecated and so on - it’s better to change only things
252252
where the default doesn’t fit your needs.
253253

254254

255-
https://github.com/Robitx/gp.nvim/blob/2169a731aec0108ad545b68bd95ef705e6c0e27b/lua/gp/config.lua#L8-L569
255+
https://github.com/Robitx/gp.nvim/blob/3adf3dc7589f54cf7af887879c995aa9846aace5/lua/gp/config.lua#L8-L568
256256

257257

258258
==============================================================================
@@ -396,7 +396,7 @@ Provides custom context per repository:
396396
SPEECH COMMANDS *gp.nvim-speech-commands*
397397

398398

399-
:GpWhisper *:GpWhisper*
399+
:GpWhisper {lang?} *:GpWhisper*
400400

401401
Transcription replaces the current line, visual selection or range in the
402402
current buffer. Use your mouth to ask a question in a chat buffer instead of
@@ -407,6 +407,9 @@ For the rest of the whisper commands, the transcription is used as an editable
407407
prompt for the equivalent non whisper command - `GpWhisperRewrite` dictates
408408
instructions for `GpRewrite` etc.
409409

410+
You can override the default language by setting {lang} with the 2 letter
411+
shortname of your language (e.g. "en" for English, "fr" for French etc).
412+
410413

411414
:GpWhisperRewrite *:GpWhisperRewrite*
412415

lua/gp/init.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ M.prepare_commands = function()
11521152
end
11531153

11541154
M.cmd["Whisper" .. command] = function(params)
1155-
M.Whisper(function(text)
1155+
M.Whisper(M.config.whisper_language, function(text)
11561156
vim.schedule(function()
11571157
cmd(params, text)
11581158
end)
@@ -3269,7 +3269,7 @@ M.Prompt = function(params, target, agent, template, prompt, whisper)
32693269
end
32703270

32713271
---@param callback function # callback function(text)
3272-
M.Whisper = function(callback)
3272+
M.Whisper = function(language, callback)
32733273
-- make sure sox is installed
32743274
if vim.fn.executable("sox") == 0 then
32753275
M.error("sox is not installed")
@@ -3425,7 +3425,7 @@ M.Whisper = function(callback)
34253425
.. M.config.openai_api_key
34263426
.. '" -H "Content-Type: multipart/form-data" '
34273427
.. '-F model="whisper-1" -F language="'
3428-
.. M.config.whisper_language
3428+
.. language
34293429
.. '" -F file="@final.mp3" '
34303430
.. '-F response_format="json"'
34313431

@@ -3528,7 +3528,14 @@ M.cmd.Whisper = function(params)
35283528
end_line = params.line2
35293529
end
35303530

3531-
M.Whisper(function(text)
3531+
local args = vim.split(params.args, " ")
3532+
3533+
local language = config.whisper_language
3534+
if args[1] ~= "" then
3535+
language = args[1]
3536+
end
3537+
3538+
M.Whisper(language, function(text)
35323539
if not vim.api.nvim_buf_is_valid(buf) then
35333540
return
35343541
end

0 commit comments

Comments
 (0)