From 5cc8a4e10daee252187124537eba428c5abfa839 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:48:11 +0200 Subject: [PATCH 1/3] add .editorconfig to help contributions set tab by default --- .editorconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..ee480627 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +indent_style = tab +indent_size = 1 +tab_width = 4 +end_of_line = lf +insert_final_newline = true +charset = utf-8 + From 44f62561f3992e8d245cdb7f13c5716fdf7984b8 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:46:43 +0100 Subject: [PATCH 2/3] make it possible tu use `:GpWhisper ` so this can be changed on the fly. --- lua/gp/init.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lua/gp/init.lua b/lua/gp/init.lua index 68755eaf..a0d14f03 100644 --- a/lua/gp/init.lua +++ b/lua/gp/init.lua @@ -1161,7 +1161,7 @@ M.prepare_commands = function() end M.cmd["Whisper" .. command] = function(params) - M.Whisper(function(text) + M.Whisper(M.config.whisper_language, function(text) vim.schedule(function() cmd(params, text) end) @@ -3200,7 +3200,7 @@ M.Prompt = function(params, target, prompt, model, template, system_template, wh end ---@param callback function # callback function(text) -M.Whisper = function(callback) +M.Whisper = function(language, callback) -- make sure sox is installed if vim.fn.executable("sox") == 0 then M.error("sox is not installed") @@ -3356,7 +3356,7 @@ M.Whisper = function(callback) .. M.config.openai_api_key .. '" -H "Content-Type: multipart/form-data" ' .. '-F model="whisper-1" -F language="' - .. M.config.whisper_language + .. language .. '" -F file="@final.mp3" ' .. '-F response_format="json"' @@ -3459,7 +3459,14 @@ M.cmd.Whisper = function(params) end_line = params.line2 end - M.Whisper(function(text) + local args = vim.split(params.args, " ") + + local language = config.whisper_language + if args[1] ~= "" then + language = args[1] + end + + M.Whisper(language, function(text) if not vim.api.nvim_buf_is_valid(buf) then return end From 6a7a78fc78f249f31cd99c3c8d9c4e419684aa53 Mon Sep 17 00:00:00 2001 From: "Matthieu C." <886074+teto@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:03:03 +0200 Subject: [PATCH 3/3] doc: updated GpWhisper doc in README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dc79c68..ad34507b 100644 --- a/README.md +++ b/README.md @@ -311,12 +311,15 @@ Provides custom context per repository: ## Speech commands -#### `:GpWhisper` +#### `:GpWhisper` {lang?} 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.. 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. +You can override the default language by setting {lang} with the 2 letter +shortname of your language (e.g. "en" for English, "fr" for French etc). + #### `:GpWhisperRewrite` Similar to `:GpRewrite`, but the prompt instruction dialog uses transcribed spoken instructions.