feat: 자막 배경 여백 · 위치 조정 모드 · CPU 추천 · 마이크 입력
Some checks failed
Windows / verify (push) Has been cancelled
Some checks failed
Windows / verify (push) Has been cancelled
요청 네 가지를 넣는다. 1) 자막 배경 여백(padding) 배경 상자를 창 전체가 아니라 **글자를 감싸는 크기**로 그리도록 바꿨다. 창 전체를 칠하던 동안에는 여백을 키워도 글자만 안으로 밀릴 뿐 배경 크기는 그대로여서, 설정 항목을 만들어도 의미가 없었다. 2) 평소 잠금 + '자막 위치 조정' locked 기본값을 True 로 바꾼다. 게임 중에 자막을 실수로 끌고 다니는 사고를 막는 쪽이 기본이어야 한다. 자막 화면의 버튼으로 조정 모드를 열면 그때만 이동·네 모서리 크기 조절·휠이 열린다. 조정 중에는 클릭 통과를 강제로 끈다 — 켜둔 채로는 마우스가 창을 지나가 잡을 수 없다. 크기를 바꾸면 글자 크기가 높이 비율을 그대로 따라간다. 상자만 커지고 글자가 그대로면 여백만 늘어나 '자막을 키우는' 조작이 되지 않는다. 조정 모드는 저장하지 않는다. 다음 실행은 다시 잠긴 상태로 시작한다. 3) GPU 가 없을 때 CPU 추천 티어 표의 recommended 는 GPU 가 넉넉할 때를 전제한 값이라, 그대로 쓰면 GPU 없는 사람에게 10GB 짜리를 권하게 된다. 환경을 보고 고르는 recommended_tier() 를 만들고 배지도 그 결과로 붙인다. GPU 가 없으면 CTranslate2 계열만 후보에 두고 가장 가벼운 쪽을 권한다 — LLM 계열은 CPU 에서 한 문장에 수십 초가 걸려 실시간 자막이 되지 않는다. '추천대로 맞추기' 버튼과, 실제로는 CPU 로 도는데 화면은 GPU 라고 표시하던 것도 같이 고친다. nvidia-smi 실패 문구가 명령줄을 통째로 토해내던 것도 사람이 읽을 문장으로 바꿨다. 4) 마이크 등 입력 장치 선택 InputDeviceCapture 를 추가하고 홈 화면에 목록 전환 버튼을 둔다. 두 목록을 한 번에 섞지 않는다 — 다 합치면 정작 찾으려던 게임이 라인입력들 사이에 파묻힌다. 버튼 글자는 '지금 상태'가 아니라 '누르면 가는 곳'을 적는다. 고른 쪽은 설정에 기억한다.
This commit is contained in:
75
tests/test_audio_sources.py
Normal file
75
tests/test_audio_sources.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""캡처 대상 목록 — 출력(게임 소리)과 입력(마이크) 전환."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from livesub import audio
|
||||
from livesub.audio import (
|
||||
SOURCE_MODE_INPUT,
|
||||
SOURCE_MODE_OUTPUT,
|
||||
AudioSource,
|
||||
CaptureError,
|
||||
InputDeviceCapture,
|
||||
create_capture,
|
||||
list_sources,
|
||||
)
|
||||
from livesub.config import AudioConfig
|
||||
|
||||
MIC = AudioSource(kind="input", identifier="3", label="마이크 (Realtek)", detail="기본 입력 장치")
|
||||
SPEAKER = AudioSource(kind="device", identifier="7", label="스피커", detail="기본 출력 장치")
|
||||
GAME = AudioSource(kind="process", identifier="4242", label="Overwatch.exe")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fake_devices(monkeypatch):
|
||||
monkeypatch.setattr(InputDeviceCapture, "available", staticmethod(lambda: True))
|
||||
monkeypatch.setattr(InputDeviceCapture, "list_sources", staticmethod(lambda: [MIC]))
|
||||
monkeypatch.setattr(
|
||||
audio.WasapiLoopbackCapture, "list_sources", staticmethod(lambda: [SPEAKER])
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
audio.ProcessLoopbackCapture, "available", staticmethod(lambda: True)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
audio.ProcessLoopbackCapture, "list_sources", staticmethod(lambda: [GAME])
|
||||
)
|
||||
|
||||
|
||||
def test_기본은_프로그램과_출력_장치를_보여준다(fake_devices):
|
||||
kinds = [s.kind for s in list_sources()]
|
||||
assert kinds == ["process", "device"]
|
||||
assert list_sources() == list_sources(SOURCE_MODE_OUTPUT)
|
||||
|
||||
|
||||
def test_입력_모드는_마이크만_보여준다(fake_devices):
|
||||
"""두 목록을 섞으면 찾으려던 게임이 라인입력 사이에 파묻힌다."""
|
||||
sources = list_sources(SOURCE_MODE_INPUT)
|
||||
assert [s.kind for s in sources] == ["input"]
|
||||
assert sources[0].label == "마이크 (Realtek)"
|
||||
|
||||
|
||||
def test_입력_장치도_장치_번호를_준다():
|
||||
assert MIC.device_index == 3
|
||||
assert MIC.pid == 0
|
||||
|
||||
|
||||
def test_입력_백엔드로_캡처를_만든다(fake_devices):
|
||||
cfg = AudioConfig(backend="input", device_index=3)
|
||||
capture = create_capture(cfg)
|
||||
assert isinstance(capture, InputDeviceCapture)
|
||||
assert capture.device_index == 3
|
||||
|
||||
|
||||
def test_입력_장치를_못_열면_이유를_알려준다(monkeypatch):
|
||||
monkeypatch.setattr(InputDeviceCapture, "available", staticmethod(lambda: False))
|
||||
with pytest.raises(CaptureError, match="입력 장치"):
|
||||
create_capture(AudioConfig(backend="input", device_index=3))
|
||||
|
||||
|
||||
def test_입력_가능_여부가_환경_보고에_들어간다():
|
||||
assert "input" in audio.capture_capabilities()
|
||||
|
||||
|
||||
def test_고른_목록_쪽을_설정에_기억한다():
|
||||
assert AudioConfig().source_mode == SOURCE_MODE_OUTPUT
|
||||
Reference in New Issue
Block a user