# HG changeset patch # User Luka Sitas # Date 1765901007 18000 # Node ID 2032796354458fadca260c795c21c525dff9cb2f # Parent 412c33afd3950c2ff037f03a14137986e3b3af5c Adding in the voice note ability. It's not perfect but it is working. diff -r 412c33afd395 -r 203279635445 .vimrc --- a/.vimrc Fri Dec 05 08:48:49 2025 -0500 +++ b/.vimrc Tue Dec 16 11:03:27 2025 -0500 @@ -14,6 +14,7 @@ source $HOME/.vim/plugins/dbtables/dbtables.vim source $HOME/.vim/plugins/hghelp/hghelp.vim source $HOME/.vim/plugins/globalsearch.vim +source $HOME/.vim/plugins/voicenote/voicenote.vim let g:db_user = "" " Replace with your default database username diff -r 412c33afd395 -r 203279635445 plugins/hghelp/hghelp.vim --- a/plugins/hghelp/hghelp.vim Fri Dec 05 08:48:49 2025 -0500 +++ b/plugins/hghelp/hghelp.vim Tue Dec 16 11:03:27 2025 -0500 @@ -7,7 +7,7 @@ execute '!'.g:hg_format_command endif execute - call ExecuteCommand('!hg addremove') + call ExecuteCommand('hg addremove') call PopupCommand('hg commit') endfunction diff -r 412c33afd395 -r 203279635445 plugins/voicenote/voicenote.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/voicenote/voicenote.vim Tue Dec 16 11:03:27 2025 -0500 @@ -0,0 +1,91 @@ +let g:audio_record_file = -1 +let g:audio_record_tmp_file = -1 +let g:audio_record_cmd = expand('~/record.sh') +let g:audio_transcribe_cmd = expand('~/transcribe.sh') +let g:audio_record_pid = -1 +let g:audio_record_transcript_file = -1 + +function! ToggleVoiceNote() + if g:audio_record_pid != -1 + call StopRecording() + call TranscribeLastRecording() + else + call StartRecording() + endif +endfunction + +function! StartRecording() + if g:audio_record_pid != -1 + echo "Recording already in progress (PID " . g:audio_record_pid . ")" + return + endif + + " Temp file where record.sh will write the WAV path + let l:temp_file = tempname() + + " Run record.sh; its stdout (the wav path) goes to temp_file. + " Then echo the background PID. + let l:cmd = printf('%s > %s 2>/dev/null & echo $!', shellescape(g:audio_record_cmd), shellescape(l:temp_file)) + + let l:pid = str2nr(system(l:cmd)) + + if l:pid <= 0 + echoerr "Failed to start recording" + return + endif + + " Read the file path written by record.sh + let g:audio_record_file = trim(system('cat ' . shellescape(l:temp_file))) + let g:audio_record_tmp_file = l:temp_file + let g:audio_record_pid = l:pid + + echo "Recording started (PID " . g:audio_record_pid . ") -> " . g:audio_record_file +endfunction + +function! StopRecording() + if g:audio_record_pid == -1 + echo "No recording in progress" + return + endif + + call system('kill ' . g:audio_record_pid) + + if g:audio_record_tmp_file != -1 + call system('rm -f ' . shellescape(g:audio_record_tmp_file)) + let g:audio_record_tmp_file = -1 + endif + + let g:audio_record_pid = -1 + let g:audio_record_transcript_file = -1 + + echo "Recording stopped." +endfunction + + +function! TranscribeLastRecording() + if g:audio_record_file == -1 + echo "No recent recording" + return + endif + + let l:cmd = printf('%s %s', shellescape(g:audio_transcribe_cmd), shellescape(g:audio_record_file)) + + " transcribe.sh echoes the .txt path + let l:transcription_file = trim(system(l:cmd)) + + if v:shell_error != 0 || empty(l:transcription_file) + echoerr "Transcription failed" + return + endif + + let g:audio_record_file = -1 + execute 'tabe' fnameescape(l:transcription_file) +endfunction + + + +" BINDINGS + +command! VoiceNote call ToggleVoiceNote() + +nnoremap vn :VoiceNote