Fix logger

This commit is contained in:
Yuta Hayashibe 2022-09-23 22:01:40 +09:00
parent ca9af389bf
commit 111e3a94a6
2 changed files with 17 additions and 2 deletions

View file

@ -2,7 +2,8 @@
import argparse
import queue
from logging import INFO, getLogger
import sys
from logging import DEBUG, INFO, StreamHandler, getLogger
from typing import Optional, Union
import sounddevice as sd
@ -83,13 +84,23 @@ def get_opts() -> argparse.Namespace:
parser.add_argument(
"--mic",
)
parser.add_argument(
"--debug",
action="store_true",
)
return parser.parse_args()
def main() -> None:
opts = get_opts()
logger.setLevel(INFO)
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:

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3
from logging import INFO, getLogger
from typing import Iterator, List, Optional, Union
import numpy as np
@ -19,6 +20,8 @@ from whisper.utils import exact_div
from whisper_streaming.schema import ParsedChunk, WhisperConfig
logger = getLogger(__name__)
class WhisperStreamingTranscriber:
def __init__(self, *, config: WhisperConfig):
@ -214,6 +217,7 @@ class WhisperStreamingTranscriber:
seek: int = 0
rest_start: Optional[int] = None
while seek < mel.shape[-1]:
logger.debug(seek)
segment = (
pad_or_trim(mel[:, :, seek:], N_FRAMES)
.to(self.model.device) # type: ignore