From 3725694cbb12ffc6cdb7416408eb846955c386d7 Mon Sep 17 00:00:00 2001 From: Yuta Hayashibe Date: Fri, 23 Sep 2022 22:11:36 +0900 Subject: [PATCH] Improved logger --- whisper_streaming/cli.py | 12 +++++------- whisper_streaming/transcriber.py | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/whisper_streaming/cli.py b/whisper_streaming/cli.py index 9bd8b29..4d3a3ec 100644 --- a/whisper_streaming/cli.py +++ b/whisper_streaming/cli.py @@ -3,7 +3,7 @@ import argparse import queue import sys -from logging import DEBUG, INFO, StreamHandler, getLogger +from logging import DEBUG, INFO, StreamHandler, basicConfig, getLogger from typing import Optional, Union import sounddevice as sd @@ -94,13 +94,11 @@ def get_opts() -> argparse.Namespace: def main() -> None: opts = get_opts() + basicConfig( + level=DEBUG if opts.debug else INFO, + format="[%(asctime)s] %(module)s.%(funcName)s %(levelname)s -> %(message)s", + ) - root_logger = getLogger() - root_logger.addHandler(StreamHandler(sys.stderr)) - if opts.debug: - root_logger.setLevel(DEBUG) - else: - root_logger.setLevel(INFO) if opts.beam_size <= 0: opts.beam_size = None try: diff --git a/whisper_streaming/transcriber.py b/whisper_streaming/transcriber.py index d444ab7..c037004 100644 --- a/whisper_streaming/transcriber.py +++ b/whisper_streaming/transcriber.py @@ -195,7 +195,7 @@ class WhisperStreamingTranscriber: ) if chunk is not None: yield chunk - self.timestamp += float(segment_duration * HOP_LENGTH / SAMPLE_RATE) + self.timestamp += duration if result.temperature > 0.5: # do not feed the prompt tokens if a high temperature was used @@ -217,7 +217,7 @@ class WhisperStreamingTranscriber: seek: int = 0 rest_start: Optional[int] = None while seek < mel.shape[-1]: - logger.debug(seek) + logger.debug(f"seek={seek}, timestamp={self.timestamp}") segment = ( pad_or_trim(mel[:, :, seek:], N_FRAMES) .to(self.model.device) # type: ignore