gui rework, removed length size selection checkboxes

This commit is contained in:
Yuriy 2024-07-31 06:00:31 -04:00
parent dd4e53e11f
commit 8b2b02ee06

View File

@ -43,12 +43,11 @@ EnvGet, ProcessorCount, NUMBER_OF_PROCESSORS
IniRead, ShutdownOnFinish, Settings.ini, %ScriptName%, ShutdownOnFinish, 0
IniRead, CPUThreads, Settings.ini, %ScriptName%, CPUThreads, %A_space%
IniRead, ShowTooltip, Settings.ini, %ScriptName%, ShowTooltip, %A_space%
IniRead, MinutesToPauseBetweenTranscriptions, Settings.ini, %ScriptName%, MinutesToPauseBetweenTranscriptions, 0
IniRead, SelectedDirectoryPath, Settings.ini, %ScriptName%, SelectedDirectoryPath, %A_space%
IniRead, TranscriptionModelsSelected, Settings.ini, %ScriptName%, TranscriptionModelsSelected, %A_space%
IniRead, TranscriptionLengthsSelected, Settings.ini, %ScriptName%, TranscriptionLengthsSelected, %A_space%
IniRead, NTFYURL, Settings.ini, %ScriptName%, NTFYURL, 0
(NTFYURL)?(NTFYURLCheckStatus := 1):(NTFYURLCheckStatus := 0)
; IniRead, TranscriptionLengthsSelected, Settings.ini, %ScriptName%, TranscriptionLengthsSelected, %A_space%
IniRead, NTFY, Settings.ini, %ScriptName%, NTFY, 0
@ -82,9 +81,9 @@ Gui, Add, Checkbox, vAllMQualities, ALL (One by One)
(instr(TranscriptionModelsSelected,"Large"))?(LargeM := 1):(LargeM := 0)
(instr(TranscriptionLengthsSelected,"Short"))?(ShortPodcastsCheckStatus := 1):(ShortPodcastsCheckStatus := 0)
(instr(TranscriptionLengthsSelected,"Medium"))?(MediumPodcastsCheckStatus := 1):(MediumPodcastsCheckStatus := 0)
(instr(TranscriptionLengthsSelected,"Long"))?(LongPodcastsCheckStatus := 1):(LongPodcastsCheckStatus := 0)
; (instr(TranscriptionLengthsSelected,"Short"))?(ShortPodcastsCheckStatus := 1):(ShortPodcastsCheckStatus := 0)
; (instr(TranscriptionLengthsSelected,"Medium"))?(MediumPodcastsCheckStatus := 1):(MediumPodcastsCheckStatus := 0)
; (instr(TranscriptionLengthsSelected,"Long"))?(LongPodcastsCheckStatus := 1):(LongPodcastsCheckStatus := 0)
; Msgbox % "ShortPodcastsCheckStatus: " ShortPodcastsCheckStatus
@ -103,9 +102,11 @@ GUIMargin := 10
VerticalLineHeight := 600
GuiRowOneWidth := 310
GUIRowTwoXPos := 350
GUIRowTwoWidth := 350
GUIRowTwoVerticalLineXPos := GUIRowTwoXPos - (10 * 2)
GUIRowTwoVerticalLineXPos := GUIRowTwoXPos - (GUIMargin)
GUIRowThreeXPos := GUIRowTwoXPos + GUIRowTwoWidth + (GUIMargin * 2)
@ -113,7 +114,7 @@ GUIRowThreeVerticalLineXPos := GUIRowThreeXPos - GUIMargin
GUIButtonWidths := 50
GUIEditBoxWidth := GUIRowTwoXPos - (GUIMargin * 4)
GUIEditBoxWidth := GUIRowTwoXPos - (GUIMargin * 8)
GuiWidth := 1100
GuiStartButtonXPos := GUIRowTwoXPos + %GUIMargin%
@ -125,51 +126,46 @@ TranscribeButtonWidth := GuiWidth - GUIRowThreeXPos - (GUIMargin * 2)
;------------------------------------------------
gui, font, s12
gui, font, s10
Gui, Font, Bold
Gui, Font, underline
Gui, Add, Text,x%GUIMargin% y%GUIMargin% w%GUIRowTwoXPos% center, Transcription Settings
Gui, Add, Button,x%GUIMargin% y%GUIMargin% w%GuiRowOneWidth% center, Transcription Settings
Gui, font, normal
; Gui, Add, Text, , Number of CPU Threads ; `nTotal Processors on PC: %ProcessorCount%
Gui, Add, Text, x%GUIMargin% y+%GUIMargin% w%GUIEditBoxWidth% center, Number of CPU Threads (PC MAX: %ProcessorCount%) ; `nTotal Processors on PC: %ProcessorCount%
Gui, Add, Edit, gUpdateGUI w%GUIEditBoxWidth%,
Gui, Add, UpDown, vCPUThreads Range1-20, %CPUThreads%
Gui, Add, Text, x%GUIMargin% y+40 w%GUIEditBoxWidth% center, Minutes to Pause After M/L Models ; `nTotal Processors on PC: %ProcessorCount%
Gui, Add, Edit, gUpdateGUI w%GUIEditBoxWidth%,
Gui, Add, UpDown, vMinutesToPauseBetweenTranscriptions Range0-20, %MinutesToPauseBetweenTranscriptions%
; Gui, Add, Text
; Gui, font, Bold
Gui, Add, Text,x%GUIMargin% y+40 w%GUIEditBoxWidth% center, Transcribe Individual File(s)
Gui, Add, Text,x%GUIMargin% y+20 w%GUIEditBoxWidth% center, Transcribe Individual File(s)
; Gui, font, normal
Gui, Add, Edit, vFilesFilepath gUpdateGUI w%GUIEditBoxWidth%
Gui, Add, Button, y+1 gSelectFile w%GUIEditBoxWidth%, Select
Gui, Add, Edit, h30 vFilesFilepath gUpdateGUI w%GUIEditBoxWidth%
Gui, Font, s8
Gui, Add, Button, x+0 w50 h30 gSelectFile, Select
; Gui, font, Bold
; Gui, Add, Text, cRed center w200 x%GUIMargin%, OR
; Gui, Add, Text,x%GUIMargin% y+40 w%GUIEditBoxWidth% center, OR
; Gui, Font, s10
Gui, Font, s12
Gui, Add, Text,x%GUIMargin% y+40 w%GUIEditBoxWidth% center, Transcribe Directory
; gui, font, s12
Gui, Add, Edit, h30 vSelectedDirectoryPath gUpdateGUI w%GUIEditBoxWidth%, %SelectedDirectoryPath%
Gui, Add, Button, y+1 w%GUIEditBoxWidth% gSelectDirectory , Select
Gui, Font, s8
Gui, Add, Button, x+0 w50 h30 gSelectDirectory, Select
; Gui, Add, Button, y+1 w%GUIEditBoxWidth% gSelectDirectory , Select
gui, add, text, y%GUIMargin% x%GUIRowTwoVerticalLineXPos% 0x11 h%VerticalLineHeight% ; 0x11 is a "line" ; refer to here: https://autohotkey.com/board/topic/50910-draw-line-gui/
Gui, Font, S10
Gui, Font, Bold
Gui, Font, underline
Gui, Add, Text,x%GUIRowTwoXPos% y%GUIMargin% w%GUIRowTwoWidth% center,Transcription Model
Gui, Add, Button,x%GUIRowTwoXPos% y%GUIMargin% w%GUIRowTwoWidth% center,Transcription Model
Gui, font, normal ; , Param2, Param3, Param4]
; Gui, Add, Radio
@ -183,24 +179,36 @@ Gui, Add, Checkbox, w%GUIRowTwoWidth% vAllMQualities, ALL (One by One)
; Gui, Add, Slider, w200 h20 Range1-5, test, one, two ; Creates a horizontal slider
Gui, Font, Bold
/*Gui, Font, Bold
Gui, Font, underline
Gui, Add, Text,x%GUIRowTwoXPos% y+15 w%GUIRowTwoXPos% center,Length of File to Transcribe
Gui, Add, Button,x%GUIRowTwoXPos% y+15 w%GUIRowTwoXPos% center,Length of File to Transcribe
Gui, font, normal
Gui, Add, Checkbox, vAnyLengthMediaFile gUpdateGUI checked%AnyLengthMediaFileCheckStatus%, ANY Length
Gui, Add, Checkbox,y+%GUIMargin% gUpdateGUI vShortPodcasts checked%ShortPodcastsCheckStatus%, Short ( < 30 Mins)
Gui, Add, Checkbox, vMediumPodcasts gUpdateGUI checked%MediumPodcastsCheckStatus%, Medium (30-60 Mins)
Gui, Add, Checkbox, vLongPodcasts gUpdateGUI checked%LongPodcastsCheckStatus%, Long ( > 60 Mins)
*/
; Gui, Add, Text, , Number of CPU Threads ; `nTotal Processors on PC: %ProcessorCount%
Gui, Font, Bold
Gui, Font, underline
Gui, Add, Button,x%GUIRowTwoXPos% y+15 w%GUIRowTwoXPos% center, Number of CPU Threads (PC MAX %ProcessorCount%)
Gui, Font, Normal
; Gui, Add, Text, x%GUIMargin% y+%GUIMargin% w%GUIEditBoxWidth% center, Number of CPU Threads (PC MAX: %ProcessorCount%) ; `nTotal Processors on PC: %ProcessorCount%
Gui, Add, Edit, gUpdateGUI w%GUIRowTwoXPos%,
Gui, Add, UpDown, vCPUThreads Range1-20, %CPUThreads%
Gui, Font, Bold
Gui, Font, underline
Gui, Add, Text,x%GUIRowTwoXPos% y+15 w%GUIRowTwoWidth% center,Other Settings
Gui, Add, Button,x%GUIRowTwoXPos% y+15 w%GUIRowTwoWidth% center,Other Settings
Gui, font, normal
Gui, Add, Checkbox, vHideCMDWindows checked%HideCMDWindows%, Hide CMD Windows
Gui, Add, Checkbox, vKeepCMDOpenOrClose checked%HideCMDWindows%, Keep CMD Open After Model Completion
Gui, Add, Checkbox, vShowTooltip checked%ShowTooltip%, Show Tooltip of Progress at Top of Screen
Gui, Add, Checkbox, vNTFYURL checked%NTFYURL%, NTFY After Each Transcription
Gui, Add, Checkbox, vNTFY checked%NTFY%, NTFY After Each Transcription
Gui, Add, Checkbox, vUploadResultToNTFY checked%UploadResultToNTFY%, Upload Transcription to NTFY
Gui, Add, Checkbox, vContinueAfterCMDClose checked%ContinueAfterCMDCloseCheckStatus%, Start After Current Running Transcription Ends
@ -306,9 +314,9 @@ if(NTFY){
IniWrite, %ShutdownOnFinish%, Settings.ini, %ScriptName%, ShutdownOnFinish
IniWrite, %CPUThreads%, Settings.ini, %ScriptName%, CPUThreads
IniWrite, %ShowTooltip%, Settings.ini, %ScriptName%, ShowTooltip
IniWrite, %MinutesToPauseBetweenTranscriptions%, Settings.ini, %ScriptName%, MinutesToPauseBetweenTranscriptions
IniWrite, %HideCMDWindows%, Settings.ini, %ScriptName%, HideCMDWindows
IniWrite, %UploadResultToNTFY%, Settings.ini, %ScriptName%, UploadResultToNTFY
IniWrite, %NTFY%, Settings.ini, %ScriptName%, NTFY
; IniWrite, %ContinueAfterCMDClose%, Settings.ini, %A_ScriptName%, ContinueAfterCMDClose
@ -437,7 +445,7 @@ if(TranscriptionModelsSelected = ""){
; save selected models to ini files
IniWrite, %TranscriptionModelsSelected%, Settings.ini, %ScriptName%, TranscriptionModelsSelected
TranscriptionLengthsSelected :=
/*TranscriptionLengthsSelected :=
(ShortPodcasts)?(TranscriptionLengthsSelected .= "Short|"):("")
(MediumPodcasts)?(TranscriptionLengthsSelected .= "Medium|"):("")
(LongPodcasts)?(TranscriptionLengthsSelected .= "Long|"):("")
@ -453,6 +461,7 @@ if(TranscriptionLengthsSelected = ""){
IniWrite, %TranscriptionLengthsSelected%, Settings.ini, %ScriptName%, TranscriptionLengthsSelected
*/
; msgbox
@ -554,44 +563,6 @@ loop % SelectedAudioFilesArray.Length() {
AudioLengthArray := StrSplit(AudioLength,":")
TotalTimeInSeconds := ((AudioLengthArray[1] * 60 ) * 60) + (AudioLengthArray[2] * 60) + AudioLengthArray[3]
if(AnyLengthMediaFile){
; continue onwards
}
else, { ; otherwise check length and skip accordingly
if(ShortPodcasts){
if(TotalTimeInSeconds > 1860){ ; greater than 31 minutes
Text = Podcast is longer than 30 minutes. Skipping
ShowTooltipText(Text)
PrePendToErrorLogText(text)
; msgbox, skipping medium/Long podcast
Continue
}
}
if(MediumPodcasts){ ; if less than 31 minutes or greater than 61 minutes
if(TotalTimeInSeconds < 1860 OR TotalTimeInSeconds > 3660){
Text = Podcast is either shorter than 30 minutes or longer than 60 minutes. Skipping
ShowTooltipText(Text)
PrePendToErrorLogText(text)
Continue
}
}
if(LongPodcasts){
if(TotalTimeInSeconds < 3660){
Text = Podcast is shorter than 60 minutes Skipping
ShowTooltipText(Text)
PrePendToErrorLogText(text)
; msgbox, skipping short/medium podcast
Continue
}
}
}
if(FileExist(WavFilepath)){ ; re-use previously converted wav file if it exists
Filepath := WavFilepath
}else, {
@ -601,8 +572,6 @@ loop % SelectedAudioFilesArray.Length() {
runwait, %ComSpec% /%KeepCMDOpenOrClose% ffmpeg -i "%Filepath%" -ar 16000 -ac 1 -c:a pcm_s16le "%WavFilepath%"
}
; msgbox, checking filepath
if(!FileExist(WavFilepath)){
Message = WAV file not found at:`n%WavFilepath%`nConversion failed for some reason.`nPlease select the "Keep CMD Open" checkbox and run again to see the error.`nClick OK to exit.
PrePendToErrorLogText(text)
@ -610,7 +579,6 @@ loop % SelectedAudioFilesArray.Length() {
}
FormatTime, TodayDate , YYYYMMDDHH24MISS,hh:mm
text = Transcription in Progress`nModel: %ModelName% CPU Threads: %CPUThreads% Length: %AudioLength%`nFile: %OutNameNoExt%`nStart Time: %TodayDate%
LogToTextFile(text, LogFileFP)
@ -621,7 +589,7 @@ loop % SelectedAudioFilesArray.Length() {
UStartTime := A_TickCount ; start time
; -mc 0 ; Fixes Model Getting stuck on same phrase ; https://github.com/ggerganov/whisper.cpp/issues/924
runwait, %ComSpec% /%KeepCMDOpenOrClose% title Podcast-Transcription-In-Progress & %A_scriptdir%\Models\main.exe -m %ModelPath% -mc 0 -f "%WavFilepath%" -t %CPUThreads% -otxt -ovtt -osrt -owts -ocsv -of "%OutputPath%"
runwait, %ComSpec% /%KeepCMDOpenOrClose% title Podcast-Transcription-In-Progress & %A_scriptdir%\Models\main.exe -m %ModelPath% -mc 0 -f "%WavFilepath%" -t %CPUThreads% -otxt -of "%OutputPath%" ; -ovtt -osrt -owts -ocsv
URunTime := round(((A_TickCount - UStartTime) / 1000), 2) ; end time
Message = Time to Transcribe: %URunTime% seconds
@ -644,36 +612,26 @@ loop % SelectedAudioFilesArray.Length() {
if(NTFY OR UploadResultToNTFY){
if(UploadResultToNTFY){
Command = "%NTFYEXEFilepath%" publish -t "%OutNameNoExt%" -f "%OutputPath%.txt" %NTFYTopic%
Status := RunCMD(Command)
}
else if(NTFY){
; Message = Transcription Complete `nNode: %A_ComputerName% `nFile: %OutNameNoExt% `nAudio Length: %AudioLength%`nModel: %ModelName%`nCPU Threads: %CPUThreads% `nTTTS: %NTFYTranscriptionTime%`nTTS 1 (s): %SecondsToTranscribe1Sec% Seconds
; Message = Transcription Complete `nNode: %A_ComputerName% `nFile: %OutNameNoExt% `nAudio Length: %AudioLength%`nModel: %ModelName%`nCPU Threads: %CPUThreads% `nTTTS: %NTFYTranscriptionTime%`nTTS 1 (s): %SecondsToTranscribe1Sec% Seconds
Command = "%NTFYEXEFilepath%" publish -t "%OutNameNoExt%" %NTFYTopic% "Transcription Complete!"
; Clipboard := Command
; Msgbox % "Command: " Command
Status := RunCMD(Command)
; Msgbox % "Status: " Status
}
else if(NTFY){
Message = Transcription Complete `nNode: %A_ComputerName% `nFile: %OutNameNoExt% `nAudio Length: %AudioLength%`nModel: %ModelName%`nCPU Threads: %CPUThreads% `nTTTS: %NTFYTranscriptionTime%`nTTS 1 (s): %SecondsToTranscribe1Sec% Seconds
SendMessagetoNTFY(Message, NTFYURL)
; Message = Transcription Complete `nNode: %A_ComputerName% `nFile: %OutNameNoExt% `nAudio Length: %AudioLength%`nModel: %ModelName%`nCPU Threads: %CPUThreads% `nTTTS: %NTFYTranscriptionTime%`nTTS 1 (s): %SecondsToTranscribe1Sec% Seconds
; SendMessagetoNTFY(Message, NTFYURL)
}
}
}
; / All transcriptions have been looped through
; take a short rest so CPU has time to cool down
; IF the last model tool longer than 10 seconds to complete (AKA not skipped over)
if(MinutesToPauseBetweenTranscriptions AND TranscriptionLength > 1000){
if(ModelName = "Medium" OR ModelName="Large"){
text = Waiting for %MinutesToPauseBetweenTranscriptions% Minutes before moving on to next item
ShowTooltipText(Text)
PrePendToErrorLogText(text)
MilisecondsToSleep := MinutesToPauseBetweenTranscriptions * 60000
sleep, %MilisecondsToSleep%
}
; reset timer for next loop
TranscriptionLength :=
}
; reset timer for next loop
TranscriptionLength :=
}
ToolTip
@ -683,14 +641,12 @@ loop % SelectedAudioFilesArray.Length() {
SendMessagetoNTFY(Message, NTFYURL)
}
msgbox, All Transcriptions have been completed.
if(ShutdownOnFinish){
Shutdown, 9 ; shutdown + power down: 1 + 8 = 9
}
else, {
msgbox, All Transcriptions have been completed.
}
return