mirror of
https://github.com/openai/whisper.git
synced 2025-11-23 22:15:58 +00:00
Merge pull request #3 from ariavn-byte/copilot/review-repo-011cv3pvca7zsctw2yquumb8
Fix critical flake8 violations: unused imports, f-string placeholders, and slice spacing
This commit is contained in:
commit
d93554a9ec
@ -4,7 +4,6 @@ Configuration settings for Farsi Transcriber application
|
||||
Manages model selection, device settings, and other configuration options.
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Application metadata
|
||||
|
||||
@ -4,7 +4,6 @@ Whisper Transcriber Module
|
||||
Handles Farsi audio/video transcription using OpenAI's Whisper model.
|
||||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional
|
||||
@ -53,7 +52,7 @@ class FarsiTranscriber:
|
||||
warnings.simplefilter("ignore")
|
||||
self.model = whisper.load_model(model_name, device=self.device)
|
||||
|
||||
print(f"Model loaded successfully")
|
||||
print("Model loaded successfully")
|
||||
|
||||
def transcribe(
|
||||
self,
|
||||
|
||||
@ -281,7 +281,7 @@ def transcribe(
|
||||
time_offset = float(seek * HOP_LENGTH / SAMPLE_RATE)
|
||||
window_end_time = float((seek + N_FRAMES) * HOP_LENGTH / SAMPLE_RATE)
|
||||
segment_size = min(N_FRAMES, content_frames - seek, seek_clip_end - seek)
|
||||
mel_segment = mel[:, seek : seek + segment_size]
|
||||
mel_segment = mel[:, seek:seek + segment_size]
|
||||
segment_duration = segment_size * HOP_LENGTH / SAMPLE_RATE
|
||||
mel_segment = pad_or_trim(mel_segment, N_FRAMES).to(model.device).to(dtype)
|
||||
|
||||
@ -444,7 +444,7 @@ def transcribe(
|
||||
continue
|
||||
if is_segment_anomaly(segment):
|
||||
next_segment = next_words_segment(
|
||||
current_segments[si + 1 :]
|
||||
current_segments[si + 1:]
|
||||
)
|
||||
if next_segment is not None:
|
||||
hal_next_start = next_segment["words"][0]["start"]
|
||||
@ -508,7 +508,7 @@ def transcribe(
|
||||
pbar.update(min(content_frames, seek) - previous_seek)
|
||||
|
||||
return dict(
|
||||
text=tokenizer.decode(all_tokens[len(initial_prompt_tokens) :]),
|
||||
text=tokenizer.decode(all_tokens[len(initial_prompt_tokens):]),
|
||||
segments=all_segments,
|
||||
language=language,
|
||||
)
|
||||
|
||||
@ -153,7 +153,7 @@ class SubtitlesWriter(ResultWriter):
|
||||
if max_words_per_line > len(segment["words"]) - chunk_index:
|
||||
words_count = remaining_words
|
||||
for i, original_timing in enumerate(
|
||||
segment["words"][chunk_index : chunk_index + words_count]
|
||||
segment["words"][chunk_index:chunk_index + words_count]
|
||||
):
|
||||
timing = original_timing.copy()
|
||||
long_pause = (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user