Improved debug logging for whisperai

pull/2412/head
JayZed 10 months ago committed by GitHub
parent 0293ea7896
commit 6ba720969e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -91,10 +91,10 @@ def configure_logging(debug=False):
warnings.simplefilter('ignore', category=PytzUsageWarning) warnings.simplefilter('ignore', category=PytzUsageWarning)
# warnings.simplefilter('ignore', category=SAWarning) # warnings.simplefilter('ignore', category=SAWarning)
if not debug: if debug:
log_level = "INFO" log_level = logging.DEBUG
else: else:
log_level = "DEBUG" log_level = logging.INFO
logger.handlers = [] logger.handlers = []
@ -106,7 +106,7 @@ def configure_logging(debug=False):
'%(asctime)-15s - %(name)-32s (%(thread)x) : %(levelname)s (%(module)s:%(lineno)d) - %(message)s') '%(asctime)-15s - %(name)-32s (%(thread)x) : %(levelname)s (%(module)s:%(lineno)d) - %(message)s')
ch.setFormatter(cf) ch.setFormatter(cf)
ch.setLevel(log_level) ch.setLevel(logging.DEBUG)
logger.addHandler(ch) logger.addHandler(ch)
# File Logging # File Logging
@ -120,7 +120,7 @@ def configure_logging(debug=False):
f = FileHandlerFormatter('%(asctime)s|%(levelname)-8s|%(name)-32s|%(message)s|', f = FileHandlerFormatter('%(asctime)s|%(levelname)-8s|%(name)-32s|%(message)s|',
'%Y-%m-%d %H:%M:%S') '%Y-%m-%d %H:%M:%S')
fh.setFormatter(f) fh.setFormatter(f)
fh.setLevel(log_level) fh.setLevel(logging.DEBUG)
logger.addHandler(fh) logger.addHandler(fh)
if debug: if debug:

@ -299,7 +299,7 @@ class WhisperAIProvider(Provider):
# tell the user what we are about to do # tell the user what we are about to do
sub.release_info = f"{sub.task} {language_from_alpha3(sub.audio_language)} audio -> {language_from_alpha3(language.alpha3)} SRT" sub.release_info = f"{sub.task} {language_from_alpha3(sub.audio_language)} audio -> {language_from_alpha3(language.alpha3)} SRT"
logger.debug(f"Whisper ({video.original_path}): {sub.audio_language} -> {language.alpha3} [TASK: {sub.task}]") logger.debug(f"Whisper query: ({video.original_path}): {sub.audio_language} -> {language.alpha3} [TASK: {sub.task}]")
return sub return sub
@ -319,6 +319,8 @@ class WhisperAIProvider(Provider):
subtitle.content = None subtitle.content = None
return return
logger.debug(f'Audio stream length (in WAV format) is {len(out):,} bytes')
if subtitle.task == "transcribe": if subtitle.task == "transcribe":
output_language = subtitle.audio_language output_language = subtitle.audio_language
else: else:
@ -334,6 +336,14 @@ class WhisperAIProvider(Provider):
endTime = time.time() endTime = time.time()
elapsedTime = timedelta(seconds=round(endTime - startTime)) elapsedTime = timedelta(seconds=round(endTime - startTime))
# for debugging, log if anything got returned
subtitle_length = len(r.content)
logger.debug(f'Returned subtitle length is {subtitle_length:,} bytes')
subtitle_length = min(subtitle_length, 1000)
if subtitle_length > 0:
logger.debug(f'First {subtitle_length} bytes of subtitle: {r.content[0:subtitle_length]}')
logger.info(f'Completed WhisperAI {subtitle.task} to {language_from_alpha3(output_language)} in {elapsedTime} for {subtitle.video.original_path}') logger.info(f'Completed WhisperAI {subtitle.task} to {language_from_alpha3(output_language)} in {elapsedTime} for {subtitle.video.original_path}')
subtitle.content = r.content subtitle.content = r.content

Loading…
Cancel
Save