mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-25 10:21:00 +00:00
Fix logger
This commit is contained in:
parent
ca9af389bf
commit
111e3a94a6
2 changed files with 17 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue