mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
Fix 'No Python frame' crash when the transcriber worker thread is quit while waiting for new tasks (#309)
This commit is contained in:
parent
f53d4a6649
commit
2d986237dc
4 changed files with 23 additions and 15 deletions
10
README.md
10
README.md
|
|
@ -7,7 +7,7 @@ OpenAI's [Whisper](https://github.com/openai/whisper).
|
|||
[](https://github.com/chidiwilliams/buzz/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/github/chidiwilliams/buzz)
|
||||

|
||||
[](https://GitHub.com/Naereen/StrapDown.js/releases/)
|
||||
[](https://GitHub.com/chidiwilliams/buzz/releases/)
|
||||
|
||||

|
||||
|
||||
|
|
@ -17,7 +17,9 @@ OpenAI's [Whisper](https://github.com/openai/whisper).
|
|||
text ([Demo](https://www.loom.com/share/564b753eb4d44b55b985b8abd26b55f7))
|
||||
- Import audio and video files and export transcripts to TXT, SRT, and
|
||||
VTT ([Demo](https://www.loom.com/share/cf263b099ac3481082bb56d19b7c87fe))
|
||||
- Supports Whisper, Whisper.cpp, and Whisper-compatible Hugging Face models
|
||||
- Supports [Whisper](https://github.com/openai/whisper#available-models-and-languages),
|
||||
[Whisper.cpp](https://github.com/ggerganov/whisper.cpp),
|
||||
and [Whisper-compatible Hugging Face models](https://huggingface.co/models?other=whisper)
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
@ -32,9 +34,11 @@ Install via [brew](https://brew.sh/):
|
|||
brew install --cask buzz
|
||||
```
|
||||
|
||||
Or, download and run the `Buzz-x.y.z.dmg` file.
|
||||
|
||||
### Windows
|
||||
|
||||
- Download and run the `Buzz-x.y.z.exe` file.
|
||||
Download and run the `Buzz-x.y.z.exe` file.
|
||||
|
||||
## How to use
|
||||
|
||||
|
|
|
|||
|
|
@ -815,7 +815,7 @@ class TranscriptionTasksTableWidget(QTableWidget):
|
|||
f'{_("In Progress")} ({task.fraction_completed :.0%})')
|
||||
elif task.status == FileTranscriptionTask.Status.COMPLETED:
|
||||
status_widget.setText(_('Completed'))
|
||||
elif task.status == FileTranscriptionTask.Status.ERROR:
|
||||
elif task.status == FileTranscriptionTask.Status.FAILED:
|
||||
status_widget.setText(_('Failed'))
|
||||
|
||||
def clear_task(self, task_id: int):
|
||||
|
|
@ -979,7 +979,7 @@ class MainWindow(QMainWindow):
|
|||
@staticmethod
|
||||
def task_completed_or_errored(task: FileTranscriptionTask):
|
||||
return task.status == FileTranscriptionTask.Status.COMPLETED or \
|
||||
task.status == FileTranscriptionTask.Status.ERROR
|
||||
task.status == FileTranscriptionTask.Status.FAILED
|
||||
|
||||
def on_clear_history_action_triggered(self):
|
||||
for task_id, task in list(self.tasks.items()):
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import logging
|
|||
import multiprocessing
|
||||
import os
|
||||
import platform
|
||||
import queue
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
|
@ -76,8 +77,7 @@ class FileTranscriptionTask:
|
|||
QUEUED = 'queued'
|
||||
IN_PROGRESS = 'in_progress'
|
||||
COMPLETED = 'completed'
|
||||
# TODO: rename to failed
|
||||
ERROR = 'error'
|
||||
FAILED = 'failed'
|
||||
|
||||
file_path: str
|
||||
transcription_options: TranscriptionOptions
|
||||
|
|
@ -585,7 +585,17 @@ class FileTranscriberQueueWorker(QObject):
|
|||
@pyqtSlot()
|
||||
def run(self):
|
||||
logging.debug('Waiting for next file transcription task')
|
||||
self.current_task: Optional[FileTranscriptionTask] = self.queue.get()
|
||||
|
||||
# Waiting for new tasks in a loop instead of with queue.wait()
|
||||
# resolves a "No Python frame" crash when the thread is quit.
|
||||
while True:
|
||||
try:
|
||||
self.current_task: Optional[FileTranscriptionTask] = self.queue.get_nowait()
|
||||
break
|
||||
except queue.Empty:
|
||||
continue
|
||||
|
||||
# Stop listening when a "None" task is received
|
||||
if self.current_task is None:
|
||||
self.completed.emit()
|
||||
return
|
||||
|
|
@ -630,7 +640,7 @@ class FileTranscriberQueueWorker(QObject):
|
|||
@pyqtSlot(str)
|
||||
def on_task_error(self, error: str):
|
||||
if self.current_task is not None:
|
||||
self.current_task.status = FileTranscriptionTask.Status.ERROR
|
||||
self.current_task.status = FileTranscriptionTask.Status.FAILED
|
||||
self.current_task.error = error
|
||||
self.task_updated.emit(self.current_task)
|
||||
|
||||
|
|
@ -649,7 +659,6 @@ class FileTranscriberQueueWorker(QObject):
|
|||
self.task_updated.emit(self.current_task)
|
||||
|
||||
def stop(self):
|
||||
# TODO: seems to crash intermittently, figure out possible race condition issues
|
||||
self.queue.put(None)
|
||||
if self.current_transcriber is not None:
|
||||
self.current_transcriber.stop()
|
||||
|
|
|
|||
5
main.py
5
main.py
|
|
@ -44,9 +44,4 @@ if __name__ == "__main__":
|
|||
|
||||
app = Application()
|
||||
|
||||
translator = QTranslator()
|
||||
locale_name = QLocale.system().name()
|
||||
if translator.load(locale_name, 'i18n'):
|
||||
app.installTranslator(translator)
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue