Skip to content

Commit

Permalink
Prevent double loading
Browse files Browse the repository at this point in the history
Prevent double loading of model twice with making captions.

Captions Module Update

* Change the text order in the captions module. (Forgot to change them when debugging oops)
* Wrapper Minor Updates
  • Loading branch information
cyberofficial committed Mar 10, 2024
1 parent 4139442 commit 6fd5b32
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
17 changes: 16 additions & 1 deletion Synthalingua_Wrapper/MainUI.vb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ Public Class MainUI
Dim unused1 = MsgBox("Please select the program file.")
Exit Sub
End If
If CAP_RadioButton.Checked = True Then
If CaptionsName.Text = "" Then
Dim unused1 = MsgBox("Please set a file name for captions.")
Exit Sub
End If
If CaptionsOutput.Text = "" Then
Dim unused1 = MsgBox("Please set the output folder.")
Exit Sub
End If
If CaptionsInput.Text = "" Then
Dim unused1 = MsgBox("Please set the input file.")
Exit Sub
End If
End If


' save ConfigTextBox.Text to a tmp bat file in the primary folder then run it
Dim tmpBatFile As String = Path.Combine(PrimaryFolder, "tmp.bat")
Expand Down Expand Up @@ -255,7 +270,7 @@ Public Class MainUI
ShortCutType = "Portable"
Else
' Show a message box to the user indicating that the file was not found
Dim unused = MsgBox("Could not find transcribe_audio.exe in the current running directory.")
Dim unused = MsgBox("Could not find transcribe_audio.exe in the current running directory. Please click the ""..."" to search for it.")
End If

' if the folder 'cookies' exist then populate CookiesName with each file name in there exclusding the file extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2024-03-10T07:38:51.0799496Z;True|2024-03-10T03:35:29.4272612-04:00;True|2024-03-10T03:33:55.4500733-04:00;True|2024-03-10T03:30:29.1421204-04:00;True|2024-03-10T03:11:38.6158306-04:00;True|2024-03-07T12:41:02.6855600-05:00;False|2024-03-07T12:40:01.3776107-05:00;</History>
<History>True|2024-03-10T10:33:16.3854689Z;True|2024-03-10T05:44:36.1805746-04:00;True|2024-03-10T03:38:51.0799496-04:00;True|2024-03-10T03:35:29.4272612-04:00;True|2024-03-10T03:33:55.4500733-04:00;True|2024-03-10T03:30:29.1421204-04:00;True|2024-03-10T03:11:38.6158306-04:00;True|2024-03-07T12:41:02.6855600-05:00;False|2024-03-07T12:40:01.3776107-05:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
6 changes: 3 additions & 3 deletions modules/sub_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def run_sub_gen(input_path: str, output_name: str = "", output_directory: str =
model_type = parser_args.set_model_by_ram(args.ram, args.language)
print("Loading Model")
model = whisper.load_model(model_type)
print("Setting Path")
print("Doing the work now...")
print("This may take a while, sit back and get a coffee or something.")
result = model.transcribe(input_path, language=args.language, task="translate")

print("Setting writer Up")
writer = get_writer("srt", str(output_directory))
print("Doing the work now...")
print("This may take a while, sit back and get a coffee or something.")

writer(result, output_name)
print("Done...")
return result, output_name
Expand Down
7 changes: 4 additions & 3 deletions transcribe_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,10 @@ def mic_calibration():
print(f"Loading model {model}...")

# remove .en from model if target_language is not set to English
if args.target_language != "en" or args.target_language != "English":
model = model.replace(".en", "")
audio_model = whisper.load_model(model, device=device, download_root="models")
if not args.makecaptions:
if args.target_language != "en" or args.target_language != "English":
model = model.replace(".en", "")
audio_model = whisper.load_model(model, device=device, download_root="models")

if args.microphone_enabled:
record_timeout = args.record_timeout
Expand Down

0 comments on commit 6fd5b32

Please sign in to comment.