mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
1080 hide ffmpeg windows (#1082)
This commit is contained in:
parent
914c5201dc
commit
3c672369a4
5 changed files with 52 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
import tempfile
|
||||
|
|
@ -68,7 +69,13 @@ class FileTranscriber(QObject):
|
|||
"-loglevel", "panic",
|
||||
wav_file]
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True)
|
||||
if sys.platform == "win32":
|
||||
si = subprocess.STARTUPINFO()
|
||||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = subprocess.SW_HIDE
|
||||
result = subprocess.run(cmd, capture_output=True, startupinfo=si)
|
||||
else:
|
||||
result = subprocess.run(cmd, capture_output=True)
|
||||
|
||||
if len(result.stderr):
|
||||
logging.warning(f"Error processing downloaded audio. Error: {result.stderr.decode()}")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
from typing import Optional, List
|
||||
|
|
@ -46,7 +47,13 @@ class OpenAIWhisperAPIFileTranscriber(FileTranscriber):
|
|||
"-i", self.transcription_task.file_path, mp3_file
|
||||
]
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True)
|
||||
if sys.platform == "win32":
|
||||
si = subprocess.STARTUPINFO()
|
||||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = subprocess.SW_HIDE
|
||||
result = subprocess.run(cmd, capture_output=True, startupinfo=si)
|
||||
else:
|
||||
result = subprocess.run(cmd, capture_output=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
logging.warning(f"FFMPEG audio load warning. Process return code was not zero: {result.returncode}")
|
||||
|
|
@ -63,10 +70,20 @@ class OpenAIWhisperAPIFileTranscriber(FileTranscriber):
|
|||
"-of", "default=noprint_wrappers=1:nokey=1",
|
||||
mp3_file,
|
||||
]
|
||||
|
||||
# fmt: on
|
||||
duration_secs = float(
|
||||
subprocess.run(cmd, capture_output=True, check=True).stdout.decode("utf-8")
|
||||
)
|
||||
if sys.platform == "win32":
|
||||
si = subprocess.STARTUPINFO()
|
||||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = subprocess.SW_HIDE
|
||||
|
||||
duration_secs = float(
|
||||
subprocess.run(cmd, capture_output=True, check=True, startupinfo=si).stdout.decode("utf-8")
|
||||
)
|
||||
else:
|
||||
duration_secs = float(
|
||||
subprocess.run(cmd, capture_output=True, check=True).stdout.decode("utf-8")
|
||||
)
|
||||
|
||||
total_size = os.path.getsize(mp3_file)
|
||||
max_chunk_size = 25 * 1024 * 1024
|
||||
|
|
@ -99,7 +116,14 @@ class OpenAIWhisperAPIFileTranscriber(FileTranscriber):
|
|||
chunk_file,
|
||||
]
|
||||
# fmt: on
|
||||
subprocess.run(cmd, capture_output=True, check=True)
|
||||
if sys.platform == "win32":
|
||||
si = subprocess.STARTUPINFO()
|
||||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = subprocess.SW_HIDE
|
||||
subprocess.run(cmd, capture_output=True, check=True, startupinfo=si)
|
||||
else:
|
||||
subprocess.run(cmd, capture_output=True, check=True)
|
||||
|
||||
logging.debug('Created chunk file "%s"', chunk_file)
|
||||
|
||||
segments.extend(
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class WhisperCpp:
|
|||
return params
|
||||
|
||||
def __del__(self):
|
||||
if self.instance:
|
||||
if self.instance and self.ctx:
|
||||
self.instance.free(self.ctx)
|
||||
|
||||
|
||||
|
|
@ -215,7 +215,8 @@ class WhisperCppCpu(WhisperCppInterface):
|
|||
return whisper_cpp.whisper_full_get_segment_t1(ctx, i)
|
||||
|
||||
def free(self, ctx):
|
||||
return whisper_cpp.whisper_free(ctx)
|
||||
if ctx and whisper_cpp is not None:
|
||||
return whisper_cpp.whisper_free(ctx)
|
||||
|
||||
|
||||
class WhisperCppCoreML(WhisperCppInterface):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from subprocess import run
|
||||
|
||||
import subprocess
|
||||
import numpy as np
|
||||
import sys
|
||||
import logging
|
||||
|
||||
SAMPLE_RATE = 16000
|
||||
|
|
@ -44,7 +44,13 @@ def load_audio(file: str, sr: int = SAMPLE_RATE):
|
|||
"-"
|
||||
]
|
||||
# fmt: on
|
||||
result = run(cmd, capture_output=True)
|
||||
if sys.platform == "win32":
|
||||
si = subprocess.STARTUPINFO()
|
||||
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = subprocess.SW_HIDE
|
||||
result = subprocess.run(cmd, capture_output=True, startupinfo=si)
|
||||
else:
|
||||
result = subprocess.run(cmd, capture_output=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
logging.warning(f"FFMPEG audio load warning. Process return code was not zero: {result.returncode}")
|
||||
|
|
|
|||
|
|
@ -263,6 +263,9 @@ class RecordingTranscriberWidget(QWidget):
|
|||
self.transcripts = []
|
||||
self.translations = []
|
||||
|
||||
self.transcription_text_box.clear()
|
||||
self.translation_text_box.clear()
|
||||
|
||||
if self.export_enabled:
|
||||
self.setup_for_export()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue