Skip to content

Commit 56263a2

Browse files
authored
Update whisperGUI.py
Added "shell" option to show the command window instead of writing the output to the main window. This can fix the problem of the output not showing in the main window.
1 parent f5bc1e2 commit 56263a2

File tree

1 file changed

+48
-35
lines changed

1 file changed

+48
-35
lines changed

whisperGUI.py

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ def main():
8181
default="",
8282
help='This textbox lets the user add other command line parameters that are not included in this GUI')
8383

84+
parser.add_argument(
85+
'--shell',
86+
action='store_true',
87+
help='check to show the shell window instead of using the Gooey window. This can fix some UTF-8 errors')
88+
8489

8590
args = parser.parse_args()
8691
#enable for debugging
@@ -134,53 +139,61 @@ def main():
134139
arg_speed = ""
135140
arg_out_srt = "--output-srt"
136141

137-
#first we process the input file with ffmpeg
138-
#workaround required to show ffmpeg output in the Gooey window
139-
#reference https://github.com/chriskiehl/Gooey/issues/355
140-
141-
startupinfo = subprocess.STARTUPINFO()
142-
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
143142

143+
#first we process the input file with ffmpeg
144144
#here we construct the command line for ffmpeg and apply the FFMPEG speedup IF selected
145145
if float(args.speed_up2) != 1.0:
146146
cmd = f"ffmpeg.exe -y -i \"{args.file}\" -ar 16000 -ac 1 -c:a pcm_s16le -af atempo={args.speed_up2} output.wav"
147147
else:
148148
cmd = f"ffmpeg.exe -y -i \"{args.file}\" -ar 16000 -ac 1 -c:a pcm_s16le output.wav"
149-
150-
#here we call the program with extra parameters to capture ffmpeg output
151-
process=subprocess.Popen(cmd,
152-
startupinfo=startupinfo,
153-
stdout=subprocess.PIPE,
154-
stdin=subprocess.PIPE,
155-
stderr=subprocess.STDOUT)
156149

157-
#here we print ffmpeg output to the Gooey window
158-
for line in process.stdout:
159-
line1=line.decode('utf-8')
160-
print(line1.rstrip())
150+
if args.shell == True:
151+
#here we call the program with extra parameters to capture ffmpeg output
152+
process=subprocess.Popen(cmd, text=True)
153+
else:
154+
#workaround required to show ffmpeg output in the Gooey window
155+
#reference https://github.com/chriskiehl/Gooey/issues/355
156+
startupinfo = subprocess.STARTUPINFO()
157+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
158+
#here we call the program with extra parameters to capture ffmpeg output
159+
process=subprocess.Popen(cmd,
160+
startupinfo=startupinfo,
161+
stdout=subprocess.PIPE,
162+
stdin=subprocess.PIPE,
163+
stderr=subprocess.STDOUT)
164+
#here we print ffmpeg output to the Gooey window
165+
for line in process.stdout:
166+
line1=line.decode('utf-8')
167+
print(line1.rstrip())
168+
161169

162170

163-
#here we run whisperCPP
164-
#workaround required to show whisperCPP output in the Gooey window
165-
#reference https://github.com/chriskiehl/Gooey/issues/355
166-
167-
startupinfo = subprocess.STARTUPINFO()
168-
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
169171

172+
#here we run whisperCPP
170173
#here we construct the command line for whisperCPP
171174
cmd = f"main.exe -f output.wav -m {args.model} -l {args.language} {arg_translate} {arg_out_txt} {arg_out_srt} {arg_out_vtt} {arg_speed} {args.others}"
172-
173-
#here we call the program with extra parameters to capture whisperCPP output
174-
process=subprocess.Popen(cmd,
175-
startupinfo=startupinfo,
176-
stdout=subprocess.PIPE,
177-
stdin=subprocess.PIPE,
178-
stderr=subprocess.STDOUT)
179-
180-
#here we print whisperCPP output to the Gooey window
181-
for line in process.stdout:
182-
line1=line.decode('utf-8')
183-
print(line1.rstrip())
175+
176+
177+
if args.shell == True:
178+
#here we call the program with extra parameters to capture ffmpeg output
179+
process=subprocess.Popen(cmd, text=True)
180+
else:
181+
182+
#workaround required to show whisperCPP output in the Gooey window
183+
#reference https://github.com/chriskiehl/Gooey/issues/355
184+
185+
startupinfo = subprocess.STARTUPINFO()
186+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
187+
#here we call the program with extra parameters to capture whisperCPP output
188+
process=subprocess.Popen(cmd,
189+
startupinfo=startupinfo,
190+
stdout=subprocess.PIPE,
191+
stdin=subprocess.PIPE,
192+
stderr=subprocess.STDOUT)
193+
#here we print whisperCPP output to the Gooey window
194+
for line in process.stdout:
195+
line1=line.decode('utf-8')
196+
print(line1.rstrip())
184197

185198
#this section fixes the timestamps of the SRT file if the FFMPEG speedup was selected
186199
#

0 commit comments

Comments
 (0)