Fix where task_queue is defined.
This commit is contained in:
36
subgen.py
36
subgen.py
@@ -125,24 +125,6 @@ in_docker = os.path.exists('/.dockerenv')
|
|||||||
docker_status = "Docker" if in_docker else "Standalone"
|
docker_status = "Docker" if in_docker else "Standalone"
|
||||||
last_print_time = None
|
last_print_time = None
|
||||||
|
|
||||||
def transcription_worker():
|
|
||||||
while True:
|
|
||||||
task = task_queue.get()
|
|
||||||
|
|
||||||
if "type" in task and task["type"] == "detect_language":
|
|
||||||
detect_language_task(task['path'])
|
|
||||||
elif 'Bazarr-' in task['path']:
|
|
||||||
logging.info(f"Task {task['path']} is being handled by ASR.")
|
|
||||||
else:
|
|
||||||
logging.info(f"Task {task['path']} is being handled by Subgen.")
|
|
||||||
gen_subtitles(task['path'], task['transcribe_or_translate'], task['force_language'])
|
|
||||||
task_queue.task_done()
|
|
||||||
# show queue
|
|
||||||
logging.debug(f"There are {task_queue.qsize()} tasks left in the queue.")
|
|
||||||
|
|
||||||
for _ in range(concurrent_transcriptions):
|
|
||||||
threading.Thread(target=transcription_worker, daemon=True).start()
|
|
||||||
|
|
||||||
class DeduplicatedQueue(queue.Queue):
|
class DeduplicatedQueue(queue.Queue):
|
||||||
"""Queue that prevents duplicates in both queued and in-progress tasks."""
|
"""Queue that prevents duplicates in both queued and in-progress tasks."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -177,6 +159,24 @@ class DeduplicatedQueue(queue.Queue):
|
|||||||
#start queue
|
#start queue
|
||||||
task_queue = DeduplicatedQueue()
|
task_queue = DeduplicatedQueue()
|
||||||
|
|
||||||
|
def transcription_worker():
|
||||||
|
while True:
|
||||||
|
task = task_queue.get()
|
||||||
|
|
||||||
|
if "type" in task and task["type"] == "detect_language":
|
||||||
|
detect_language_task(task['path'])
|
||||||
|
elif 'Bazarr-' in task['path']:
|
||||||
|
logging.info(f"Task {task['path']} is being handled by ASR.")
|
||||||
|
else:
|
||||||
|
logging.info(f"Task {task['path']} is being handled by Subgen.")
|
||||||
|
gen_subtitles(task['path'], task['transcribe_or_translate'], task['force_language'])
|
||||||
|
task_queue.task_done()
|
||||||
|
# show queue
|
||||||
|
logging.debug(f"There are {task_queue.qsize()} tasks left in the queue.")
|
||||||
|
|
||||||
|
for _ in range(concurrent_transcriptions):
|
||||||
|
threading.Thread(target=transcription_worker, daemon=True).start()
|
||||||
|
|
||||||
# Define a filter class to hide common logging we don't want to see
|
# Define a filter class to hide common logging we don't want to see
|
||||||
class MultiplePatternsFilter(logging.Filter):
|
class MultiplePatternsFilter(logging.Filter):
|
||||||
def filter(self, record):
|
def filter(self, record):
|
||||||
|
|||||||
Reference in New Issue
Block a user