Lint scripts and tests
This commit is contained in:
parent
cf6c49f502
commit
74c4dc791d
5 changed files with 17 additions and 17 deletions
|
|
@ -6,6 +6,7 @@ Produces one JSON file per audio with: [{word, start, end}, ...]
|
|||
|
||||
import json
|
||||
import os
|
||||
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
AUDIO_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ sys.path.insert(0, str(Path(__file__).parent))
|
|||
from test_backend_offline import (
|
||||
AUDIO_TESTS_DIR,
|
||||
SAMPLE_RATE,
|
||||
TestResult,
|
||||
create_engine,
|
||||
discover_audio_files,
|
||||
download_sample_audio,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import io
|
|||
import math
|
||||
import pathlib
|
||||
import sys
|
||||
from typing import List, Optional, Sequence, Tuple, Union
|
||||
from typing import Sequence, Tuple, Union
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
|
@ -24,7 +24,7 @@ sys.path.insert(0, str(REPO_ROOT))
|
|||
sys.path.insert(0, str(WHISPER_ROOT))
|
||||
|
||||
from whisper import load_model
|
||||
from whisper.audio import load_audio, log_mel_spectrogram, pad_or_trim
|
||||
from whisper.audio import log_mel_spectrogram, pad_or_trim
|
||||
from whisper.tokenizer import get_tokenizer
|
||||
|
||||
AudioInput = Union[str, pathlib.Path, np.ndarray, torch.Tensor]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
"""Copy core files from web directory to Chrome extension directory."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ import logging
|
|||
import sys
|
||||
import time
|
||||
import urllib.request
|
||||
from dataclasses import asdict, dataclass, field
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass, asdict, field
|
||||
from typing import List, Optional
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -157,6 +157,7 @@ def create_engine(
|
|||
):
|
||||
"""Create a TranscriptionEngine with the given backend config."""
|
||||
import gc
|
||||
|
||||
from whisperlivekit.core import TranscriptionEngine
|
||||
|
||||
# Reset singleton so we get a fresh instance
|
||||
|
|
@ -320,7 +321,7 @@ async def run_test(
|
|||
transcription = _extract_text_from_response(last)
|
||||
|
||||
# --- Compute WER and timestamp accuracy against ground truth ---
|
||||
from whisperlivekit.metrics import compute_wer, compute_timestamp_accuracy
|
||||
from whisperlivekit.metrics import compute_timestamp_accuracy, compute_wer
|
||||
|
||||
wer_val = None
|
||||
wer_details = None
|
||||
|
|
@ -434,7 +435,7 @@ async def run_all_tests(
|
|||
file_lan = lan
|
||||
if "french" in audio_path.name.lower() and lan == "en":
|
||||
file_lan = "fr"
|
||||
logger.info(f"Auto-detected language 'fr' from filename")
|
||||
logger.info("Auto-detected language 'fr' from filename")
|
||||
|
||||
audio = load_audio(str(audio_path))
|
||||
|
||||
|
|
@ -495,7 +496,7 @@ def print_benchmark_summary(results: List[TestResult]):
|
|||
print(f"{'=' * 110}")
|
||||
|
||||
# Print transcription excerpts
|
||||
print(f"\nTRANSCRIPTIONS:")
|
||||
print("\nTRANSCRIPTIONS:")
|
||||
print(f"{'-' * 110}")
|
||||
for r in results:
|
||||
excerpt = r.transcription[:120] + "..." if len(r.transcription) > 120 else r.transcription
|
||||
|
|
|
|||
Loading…
Reference in a new issue