mirror of
https://github.com/shirayu/whispering.git
synced 2025-03-28 04:55:28 +00:00
Improved logger
This commit is contained in:
parent
111e3a94a6
commit
3725694cbb
2 changed files with 7 additions and 9 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue