feat(scaffold): добавлена начальная структура проекта local-transcriber
- Зачем: - необходима базовая структура пакета для последовательной реализации шагов по плану. - Что: - создан pyproject.toml с зависимостями typer, rich и dev-зависимостью pytest. - добавлены модули-заглушки cli.py, transcriber.py, formatter.py, utils.py с сигнатурами и raise NotImplementedError. - созданы пустые тестовые файлы test_formatter.py, test_transcriber.py, test_utils.py. - добавлены .gitignore и uv.lock; отмечены чекбоксы шага 1 в docs/plan.md. - Проверка: - uv run transcribe --help — показывает аргументы. - uv run pytest — тесты обнаруживаются без ошибок. - python -c "from local_transcriber import cli, transcriber, formatter, utils" — импорт без ошибок.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
from pathlib import Path
|
||||
|
||||
import typer
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
|
||||
@app.command()
|
||||
def main(file: Path) -> None:
|
||||
typer.echo("TODO: not implemented")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
@@ -0,0 +1,23 @@
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from .transcriber import TranscribeResult
|
||||
|
||||
|
||||
def format_timestamp(seconds: float, use_hours: bool = False) -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def format_transcript(
|
||||
result: TranscribeResult,
|
||||
source_filename: str,
|
||||
model_name: str,
|
||||
device_info: str,
|
||||
language_mode: str, # "detected" | "forced"
|
||||
transcription_date: datetime | None = None, # None -> datetime.now()
|
||||
) -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def write_transcript(content: str, output_path: Path) -> None:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,30 @@
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@dataclass
|
||||
class Segment:
|
||||
start: float # seconds
|
||||
end: float # seconds
|
||||
text: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class TranscribeResult:
|
||||
segments: list[Segment]
|
||||
language: str
|
||||
language_probability: float
|
||||
duration: float # seconds
|
||||
device_used: str # "cpu" / "cuda"
|
||||
|
||||
|
||||
def transcribe(
|
||||
file_path: Path,
|
||||
model_name: str = "large-v3",
|
||||
device: str = "auto",
|
||||
compute_type: str = "int8",
|
||||
language: str | None = None,
|
||||
on_segment: Callable[[Segment], None] | None = None,
|
||||
) -> TranscribeResult:
|
||||
raise NotImplementedError
|
||||
@@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def check_ffmpeg() -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def detect_device(requested: str = "auto") -> str:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def get_gpu_name() -> str | None:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def validate_input_file(path: Path) -> Path:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def build_output_path(input_path: Path, output: Path | None = None) -> Path:
|
||||
raise NotImplementedError
|
||||
Reference in New Issue
Block a user