- app/src/main: Electron 메인(트레이 상태 아이콘, 설정 창, 단일 실행, DPAPI safeStorage, 스모크 모드), IPC(window.gvr), 파인튜닝 관리 - app/src/renderer: 설정 8개 탭 + 5단계 첫 실행 마법사 (React) - electron-builder: GameVoiceRecorder.exe, zip(폴더 포터블) + 단일 exe 포터블, 워커·리소스 포함 - 사전: 사이트에서 단어·교정 규칙 추가/삭제(/api/dictionary), 게임 패치 이름 자동 추가, 묶음별 중복 허용 + DB 마이그레이션 - 사이트 서버: 종료 시 WebSocket 먼저 끊기(재시작 멈춤 수정) + 재연결 테스트 - scripts/finetune-e2e.mts, stt-eval.mts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
198 lines
7.3 KiB
TypeScript
198 lines
7.3 KiB
TypeScript
// STT 탭과 마법사 3단계가 함께 쓰는 GPU 카드 · 모델 카드 · 다운로드 진행
|
||
import { useEffect, useRef, type ReactNode } from 'react';
|
||
import type { DownloadProgress, GpuInfo, ModelsInfo } from '../main/api-types';
|
||
import { metaFor, stars, vramFor, ctShort } from './models-meta';
|
||
import { gvr, useApp, useLoad } from './store';
|
||
import { Bar, Spinner } from './ui';
|
||
import { fmtEta, fmtMb } from './util';
|
||
|
||
function arch(cc?: string): string | null {
|
||
if (!cc) return null;
|
||
const major = Number(cc.split('.')[0]);
|
||
const v = Number(cc);
|
||
if (major >= 12 || major === 10) return 'Blackwell';
|
||
if (v >= 8.9) return 'Ada Lovelace';
|
||
if (major === 8) return 'Ampere';
|
||
if (v >= 7.5) return 'Turing';
|
||
return null;
|
||
}
|
||
|
||
/** GPU · 모델 목록을 불러오고, 다운로드가 끝나면 모델 목록을 다시 읽는다 */
|
||
export function useSttData() {
|
||
const { downloads } = useApp();
|
||
const gpu = useLoad(() => gvr.gpuInfo());
|
||
const models = useLoad(() => gvr.models());
|
||
const doneKeys = Object.values(downloads)
|
||
.filter((d) => d.state === 'done')
|
||
.map((d) => d.key)
|
||
.join(',');
|
||
const first = useRef(true);
|
||
useEffect(() => {
|
||
if (first.current) {
|
||
first.current = false;
|
||
return;
|
||
}
|
||
void models.reload();
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||
}, [doneKeys]);
|
||
return { gpu, models };
|
||
}
|
||
|
||
export function GpuCard({ info, loading, error }: { info: GpuInfo | null; loading: boolean; error?: string | null }) {
|
||
const { settings } = useApp();
|
||
const s = settings.stt;
|
||
const g = info?.gpus[0];
|
||
if (loading && !info)
|
||
return (
|
||
<div className="gpu">
|
||
<div className="chipicon">🖥️</div>
|
||
<div className="muted">
|
||
<Spinner /> GPU 확인 중…
|
||
</div>
|
||
</div>
|
||
);
|
||
if (!g)
|
||
return (
|
||
<div className="gpu warn">
|
||
<div className="chipicon">⚠️</div>
|
||
<div>
|
||
<div style={{ fontWeight: 700 }}>NVIDIA GPU를 찾지 못했습니다</div>
|
||
<div className="dim small">{error ?? 'STT는 CPU로 동작하며 매우 느립니다. 드라이버 설치 후 다시 열어 보세요.'}</div>
|
||
</div>
|
||
</div>
|
||
);
|
||
const total = g.vram_total_mb;
|
||
const reserve = s.gameVramReserveMb;
|
||
const rt = vramFor(s.realtimeModel, s.computeType);
|
||
const showPrecise = s.reprocessAfterMatch && s.preciseModel !== s.realtimeModel;
|
||
const pr = showPrecise ? vramFor(s.preciseModel, s.computeType) : 0;
|
||
const free = total - reserve - rt - pr;
|
||
const pct = (mb: number) => `${(Math.max(0, mb) / total) * 100}%`;
|
||
const gb = (mb: number) => `${(mb / 1024).toFixed(1).replace(/\.0$/, '')}GB`;
|
||
const rec = info.recommend;
|
||
const a = arch(g.compute_capability);
|
||
return (
|
||
<div className="gpu">
|
||
<div className="chipicon">🖥️</div>
|
||
<div style={{ flex: 1, minWidth: 0 }}>
|
||
<div className="gpu-name">
|
||
<b>{g.name}</b>
|
||
<span className="muted">
|
||
{' '}
|
||
· VRAM {Math.round(total / 1024)}GB{a ? ` · ${a}` : ''} · 드라이버 {g.driver}
|
||
{g.cuda_driver ? ` · CUDA ${g.cuda_driver}` : ''} {rec.supported === false ? '' : '✓'}
|
||
</span>
|
||
</div>
|
||
<div className="budget">
|
||
<i style={{ width: pct(reserve), background: '#3987e5' }}>게임 예약 {gb(reserve)}</i>
|
||
<i style={{ width: pct(rt), background: '#e5743f' }}>실시간 {gb(rt)}</i>
|
||
{showPrecise && (
|
||
<i style={{ width: pct(pr), background: '#c8aa6e', color: '#1e1a12' }}>
|
||
경기 후 정밀 {gb(pr)}
|
||
</i>
|
||
)}
|
||
{free > 0 && <i style={{ width: pct(free), background: '#2b3a48', color: '#9fb0c0' }}>여유 {gb(free)}</i>}
|
||
</div>
|
||
{free < 0 ? (
|
||
<div className="err small">VRAM이 {gb(-free)} 모자랍니다. 더 작은 모델이나 int8_float16을 고르세요.</div>
|
||
) : (
|
||
<div className="dim small">게임이 쓸 VRAM(두 게임 중 큰 값)을 먼저 빼고 남은 공간에서 고릅니다. 정밀 모델은 경기가 끝난 뒤에만 올립니다.</div>
|
||
)}
|
||
{rec.warning && <div className="warn-text small">⚠ {rec.warning}</div>}
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|
||
|
||
export type ModelRole = 'realtime' | 'precise' | 'both' | null;
|
||
|
||
export function ModelCard({
|
||
name,
|
||
info,
|
||
role,
|
||
recommended,
|
||
dim,
|
||
footer,
|
||
extraRow,
|
||
onClick,
|
||
}: {
|
||
name: string;
|
||
info?: ModelsInfo['models'][number];
|
||
role: ModelRole;
|
||
recommended?: string[];
|
||
dim?: boolean;
|
||
footer?: ReactNode;
|
||
extraRow?: ReactNode;
|
||
onClick?: () => void;
|
||
}) {
|
||
const { settings } = useApp();
|
||
const m = metaFor(name);
|
||
const ct = settings.stt.computeType;
|
||
const tag = role === 'realtime' ? '실시간' : role === 'precise' ? '경기 후 정밀' : role === 'both' ? '실시간 · 정밀' : null;
|
||
return (
|
||
<div className={`m ${role === 'precise' ? 'rec gold' : role ? 'rec' : ''} ${dim ? 'dimmed' : ''} ${onClick ? 'click' : ''}`} onClick={onClick}>
|
||
{tag && <span className="tag">{recommended?.length ? `${tag} 추천` : tag}</span>}
|
||
<h3 className="h">
|
||
{name}
|
||
</h3>
|
||
<div className="stars">{stars(m.stars)}</div>
|
||
<div className="row">
|
||
정확도<b>{m.acc}</b>
|
||
</div>
|
||
<div className="row">
|
||
VRAM<b>
|
||
약 {fmtMb(vramFor(name, ct))} ({ctShort(ct)})
|
||
</b>
|
||
</div>
|
||
{extraRow ?? (
|
||
<div className="row">
|
||
다운로드<b>약 {fmtMb(info?.size_mb ?? m.sizeMb)}</b>
|
||
</div>
|
||
)}
|
||
{recommended && recommended.length > 0 && !tag && <div className="rec-note">★ {recommended.join(' · ')} 추천</div>}
|
||
{(footer || info?.installed) && (
|
||
<div className="m-foot">
|
||
{info?.installed && <span className="badge inst">설치됨 ✓</span>}
|
||
<span className="grow" />
|
||
{footer}
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|
||
|
||
export function dlLabel(key: string): string {
|
||
return key === 'cuda_runtime' ? 'CUDA 런타임' : key.replace(/^model:/, '');
|
||
}
|
||
|
||
export function DownloadRow({ p, next }: { p: DownloadProgress; next?: string }) {
|
||
const pct = p.total_mb ? (p.done_mb / p.total_mb) * 100 : 0;
|
||
const big = p.total_mb >= 1000;
|
||
const amount = big ? `${(p.done_mb / 1024).toFixed(1)} / ${(p.total_mb / 1024).toFixed(1)} GB` : `${Math.round(p.done_mb)} / ${Math.round(p.total_mb)} MB`;
|
||
return (
|
||
<div className={`prog ${p.state}`}>
|
||
<div className="prog-head">
|
||
<b>
|
||
{dlLabel(p.key)} {p.state === 'done' ? '다운로드 완료' : p.state === 'error' ? '다운로드 실패' : '다운로드 중'}
|
||
{p.stage && p.state === 'running' && <span className="muted small"> · {p.stage}</span>}
|
||
</b>
|
||
<span className="mono muted">
|
||
{p.state === 'running'
|
||
? [amount, p.speed_mbps !== undefined && `${p.speed_mbps.toFixed(0)} MB/s`, p.eta_s !== undefined && `남은 시간 ${fmtEta(p.eta_s)}`].filter(Boolean).join(' · ')
|
||
: p.state === 'done'
|
||
? `${fmtMb(p.total_mb)} ✓`
|
||
: ''}
|
||
</span>
|
||
</div>
|
||
<Bar pct={p.state === 'done' ? 100 : pct} className={p.state} />
|
||
{p.state === 'error' ? (
|
||
<div className="err small">{p.error ?? '알 수 없는 오류'} · 다시 누르면 이어받습니다</div>
|
||
) : (
|
||
<div className="dim small">
|
||
{next ? `다음: ${next} · ` : ''}끊겨도 이어받기 지원
|
||
</div>
|
||
)}
|
||
</div>
|
||
);
|
||
}
|