first 'working' version
This commit is contained in:
@@ -190,6 +190,9 @@ def get_progress(job_name: str, config: dict) -> int:
|
||||
input_dir = os.path.join(config['jobs']['root_directory'], job_name, chunk_input_subdir)
|
||||
output_dir = os.path.join(config['jobs']['root_directory'], job_name, chunk_output_subdir)
|
||||
|
||||
if not os.path.exists(input_dir) or not os.path.exists(output_dir):
|
||||
return 0
|
||||
|
||||
num_input_files = len(os.listdir(input_dir))
|
||||
num_output_files = len(os.listdir(output_dir))
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ import os
|
||||
from multiprocessing import Lock
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
|
||||
import job_utils
|
||||
from utils import get_logger
|
||||
from audio_processing import split_audio, convert_to_wav
|
||||
from job_utils import is_job, remove_job, create_job, get_processing, set_processing
|
||||
from transcription import transcribe_audio
|
||||
from transcription import job_utils
|
||||
from transcription.job_utils import is_job, remove_job, create_job, get_processing, set_processing
|
||||
from transcription.audio_processing import split_audio, convert_to_wav
|
||||
from transcription.transcription import transcribe_audio
|
||||
|
||||
job_update_lock = Lock()
|
||||
default_input_audio_file_name = 'input_audio'
|
||||
@@ -36,7 +36,7 @@ def transcribe(audio_file_path: str,
|
||||
job_name = os.path.basename(audio_file_path).split('.')[0]
|
||||
job_dir = os.path.join(config['jobs']['root_directory'], job_name)
|
||||
|
||||
logger.info(f"Transcribing {audio_file_path} to {job_dir}")
|
||||
logger.info(f"Transcribing {audio_file_path} to {job_dir}, blocking={blocking}, overwrite={overwrite}")
|
||||
|
||||
# check, if a job with the same audio file already exists
|
||||
job_already_exists = is_job(job_name, config)
|
||||
@@ -129,7 +129,7 @@ def run_transcription_job(job_name: str,
|
||||
logger.info(f'Combining output text chunks for job {job_name}')
|
||||
output_chunk_folder = os.path.join(config['jobs']['root_directory'], job_name, job_utils.chunk_output_subdir)
|
||||
output_text = ''
|
||||
for text_chunk_file in sorted(os.listdir(output_chunk_folder)):
|
||||
for text_chunk_file in sorted(os.listdir(output_chunk_folder), key=lambda x: int(x.split('_')[1].split('.')[0])):
|
||||
with open(os.path.join(output_chunk_folder, text_chunk_file), 'r') as text_chunk:
|
||||
output_text += text_chunk.read() + ' '
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import sys
|
||||
import logging
|
||||
from logging import Logger
|
||||
|
||||
|
||||
def get_logger(name: str) -> Logger:
|
||||
"""
|
||||
Get a logger instance.
|
||||
:param name: name of the logger
|
||||
:return: logger instance
|
||||
"""
|
||||
logger = logging.getLogger(name)
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
# create a file handler
|
||||
file_handler = logging.FileHandler(f'{name}.log')
|
||||
file_handler.setLevel(logging.INFO)
|
||||
|
||||
# create stdout handler
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
stdout_handler.setLevel(logging.INFO)
|
||||
|
||||
# create a logging format
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
file_handler.setFormatter(formatter)
|
||||
stdout_handler.setFormatter(formatter)
|
||||
|
||||
# add the handlers to the logger
|
||||
logger.addHandler(file_handler)
|
||||
logger.addHandler(stdout_handler)
|
||||
|
||||
return logger
|
||||
Reference in New Issue
Block a user