Files
voice-to-notes/python/tests/test_transcribe.py
Josh Knapp 48fe41b064 Phase 2: Core transcription pipeline and audio playback
- Implement faster-whisper TranscribeService with word-level timestamps,
  progress reporting, and hardware auto-detection
- Wire up Rust SidecarManager for Python process lifecycle (spawn, IPC, shutdown)
- Add transcribe_file Tauri command bridging frontend to Python sidecar
- Integrate wavesurfer.js WaveformPlayer with play/pause, skip, seek controls
- Build TranscriptEditor with word-level click-to-seek and active highlighting
- Connect file import flow: prompt → asset load → transcribe → display
- Add typed tauri-bridge service with TranscriptionResult interface
- Add Python tests for hardware detection and transcription result formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 15:53:09 -08:00

52 lines
1.4 KiB
Python

"""Tests for transcription service."""
from voice_to_notes.services.transcribe import (
SegmentResult,
TranscriptionResult,
WordResult,
result_to_payload,
)
def test_result_to_payload():
"""Test converting TranscriptionResult to IPC payload."""
result = TranscriptionResult(
segments=[
SegmentResult(
text="hello world",
start_ms=0,
end_ms=2000,
words=[
WordResult(word="hello", start_ms=0, end_ms=500, confidence=0.95),
WordResult(word="world", start_ms=600, end_ms=2000, confidence=0.92),
],
),
],
language="en",
language_probability=0.98,
duration_ms=2000,
)
payload = result_to_payload(result)
assert payload["language"] == "en"
assert payload["duration_ms"] == 2000
assert len(payload["segments"]) == 1
seg = payload["segments"][0]
assert seg["text"] == "hello world"
assert seg["start_ms"] == 0
assert seg["end_ms"] == 2000
assert len(seg["words"]) == 2
assert seg["words"][0]["word"] == "hello"
assert seg["words"][0]["confidence"] == 0.95
def test_result_to_payload_empty():
"""Test empty transcription result."""
result = TranscriptionResult()
payload = result_to_payload(result)
assert payload["segments"] == []
assert payload["language"] == ""
assert payload["duration_ms"] == 0