게임 중 GPU 아끼기: 게임(발로란트 실행 중 · 롤 경기 중)이 켜져 있으면 정밀 모델을 내리고 정밀 변환은 게임을 끈 뒤로 (16GB 카드는 경기 중에도 large-v3 를 올려 두고 다음 경기 중에도 지난 경기 정밀 변환을 돌리던 것, 메뉴에서는 새 발화를 large-v3 빔 5 로 변환하던 것) · 실시간 변환은 빔 1 · 발화 사이에 변환한 만큼 쉼 · 설정 토글 · 앱 창 하드웨어 가속 끔
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,10 @@ export class LolAdapter implements GameAdapter {
|
||||
status() {
|
||||
return { connected: !!this.lcu || !!this.live, inMatch: !!this.live && !this.live.ended, detail: this.lastErr || undefined };
|
||||
}
|
||||
/** 롤은 경기 중에만 (클라이언트 화면은 가볍다) */
|
||||
gameRunning(): boolean {
|
||||
return !!this.live && !this.live.ended;
|
||||
}
|
||||
|
||||
liveGame(): LiveGame {
|
||||
const enabled = this.host.settings().games.lol;
|
||||
|
||||
@@ -73,6 +73,7 @@ export class GameManager implements AdapterHost {
|
||||
private watchLive(): void {
|
||||
if (this.liveTimer) return;
|
||||
this.liveTimer = setInterval(() => {
|
||||
void this.stt.setGameActive(this.adapters.some((a) => this.settings().games[a.game] && a.gameRunning()));
|
||||
const live = this.live();
|
||||
const key = JSON.stringify(live.map(({ updatedAt: _u, ...rest }) => rest));
|
||||
if (key === this.lastLive) return;
|
||||
|
||||
@@ -39,6 +39,8 @@ export interface GameAdapter {
|
||||
start(): void;
|
||||
stop(): void;
|
||||
status(): { connected: boolean; inMatch: boolean; detail?: string };
|
||||
/** 게임이 켜져 있어 GPU 를 쓰고 있는가 (발로란트: 게임 실행 중 · 롤: 경기 중) */
|
||||
gameRunning(): boolean;
|
||||
/** 지금 게임 상태 (자세히) */
|
||||
liveGame(): LiveGame;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,10 @@ export class ValorantAdapter implements GameAdapter {
|
||||
status() {
|
||||
return { connected: !!this.auth, inMatch: !!this.match, detail: this.lastErr || undefined };
|
||||
}
|
||||
/** 발로란트는 메뉴에서도 게임 화면을 그린다: 게임이 켜져 있으면(내 발로란트 상태가 있으면) 켜짐 */
|
||||
gameRunning(): boolean {
|
||||
return !!this.match || (!!this.auth && !!this.presence);
|
||||
}
|
||||
|
||||
liveGame(): LiveGame {
|
||||
const p = this.presence;
|
||||
@@ -206,9 +210,10 @@ export class ValorantAdapter implements GameAdapter {
|
||||
if (a) {
|
||||
await this.pollPresence(a);
|
||||
if (this.match) await this.pollChat(a);
|
||||
} else if (this.match) {
|
||||
} else {
|
||||
this.presence = null;
|
||||
// 클라이언트가 꺼졌으면 경기도 끝난 것으로 본다
|
||||
this.endMatch();
|
||||
if (this.match) this.endMatch();
|
||||
}
|
||||
await this.pollDetails();
|
||||
this.lastErr = '';
|
||||
|
||||
@@ -33,6 +33,8 @@ export interface Settings {
|
||||
modelsDir: string | null;
|
||||
reprocessAfterMatch: boolean;
|
||||
gameVramReserveMb: number;
|
||||
/** 게임이 켜져 있는 동안 GPU 를 아낀다: 실시간 모델만 가볍게(빔 1) · 쉬어 가며, 정밀 모델 변환은 게임을 끈 뒤로 (v1.9.0) */
|
||||
gameSaver: boolean;
|
||||
};
|
||||
audio: {
|
||||
targetLufs: number;
|
||||
@@ -111,6 +113,7 @@ export function defaultSettings(): Settings {
|
||||
modelsDir: null,
|
||||
reprocessAfterMatch: true,
|
||||
gameVramReserveMb: 3072,
|
||||
gameSaver: true,
|
||||
},
|
||||
audio: { targetLufs: -18, denoise: false, noiseSensitivity: 0.5, silenceMs: 800, maxUtteranceSec: 30 },
|
||||
dictionary: {
|
||||
|
||||
@@ -100,6 +100,12 @@ export class SttPipeline {
|
||||
return c ? Number(c) : null;
|
||||
}
|
||||
private inMatch = false;
|
||||
/** 게임(발로란트 · 롤 경기)이 켜져 있다 (GameManager 가 2초마다 알려 줌) */
|
||||
private gameActive = false;
|
||||
/** 게임 중 GPU 아끼기: 켜져 있고 게임 중일 때 */
|
||||
private saving(): boolean {
|
||||
return this.gameActive && this.settings().stt.gameSaver !== false;
|
||||
}
|
||||
/** 두 모델을 동시에 올릴 VRAM 이 되는가 (워커 추천값) */
|
||||
private bothFit = true;
|
||||
status: SttStatus = {
|
||||
@@ -143,10 +149,46 @@ export class SttPipeline {
|
||||
this.bothFit = false;
|
||||
}
|
||||
await this.load('realtime', s.realtimeModel);
|
||||
if (this.bothFit && !this.inMatch) await this.load('precise', s.preciseModel);
|
||||
if (this.bothFit && !this.inMatch && !this.saving()) await this.load('precise', s.preciseModel);
|
||||
this.pump();
|
||||
}
|
||||
|
||||
/**
|
||||
* 게임이 켜지고 꺼질 때 (v1.9.0). 게임 중 GPU 아끼기가 켜져 있으면
|
||||
* 켜질 때 정밀 모델을 내리고(정밀 변환은 대기열에서 기다림), 꺼지면 다시 올려 밀린 정밀 변환을 한다.
|
||||
*/
|
||||
async setGameActive(on: boolean): Promise<void> {
|
||||
if (this.gameActive === on) return;
|
||||
this.gameActive = on;
|
||||
const s = this.settings().stt;
|
||||
if (on) {
|
||||
if (s.gameSaver === false) return;
|
||||
log.info('게임 켜짐: GPU 아끼기 (실시간 모델만 가볍게, 정밀 변환은 게임을 끈 뒤)');
|
||||
if (this.status.slots.precise.state === 'loaded') await this.unload('precise');
|
||||
return;
|
||||
}
|
||||
if (s.gameSaver !== false || this.queue.some((j) => j.slot === 'precise')) log.info('게임 꺼짐: 밀린 정밀 변환 시작');
|
||||
if (this.status.worker !== 'ready') return; // 워커가 켜지면 prepareModels 가 이어서 한다
|
||||
const wantPrecise = this.queue.some((j) => j.slot === 'precise') || this.bothFit;
|
||||
if (wantPrecise) await this.load('precise', s.preciseModel);
|
||||
if (this.gameActive) return; // 올리는 동안 게임이 다시 켜짐
|
||||
// 정밀 모델이 없으면(설치 안 됨 · 실패) 기다리던 정밀 변환은 버린다 (실시간 결과가 그대로 남음)
|
||||
if (this.status.slots.precise.state !== 'loaded') this.dropPrecise();
|
||||
else if (!this.bothFit && !this.queue.some((j) => j.slot === 'precise')) await this.unload('precise');
|
||||
this.pump();
|
||||
}
|
||||
|
||||
private dropPrecise(): void {
|
||||
const before = this.queue.length;
|
||||
this.queue = this.queue.filter((j) => {
|
||||
if (j.slot !== 'precise') return true;
|
||||
this.queued.delete(`precise:${j.id}`);
|
||||
return false;
|
||||
});
|
||||
this.status.queue = this.queue.length;
|
||||
if (before !== this.queue.length) log.info(`정밀 모델이 없어 정밀 변환 ${before - this.queue.length}개를 건너뜀`);
|
||||
}
|
||||
|
||||
private async installed(): Promise<Set<string>> {
|
||||
try {
|
||||
const r = await this.worker.request('models', {}, 30000);
|
||||
@@ -223,6 +265,13 @@ export class SttPipeline {
|
||||
this.inMatch = false;
|
||||
const s = this.settings().stt;
|
||||
if (!s.reprocessAfterMatch || s.preciseModel === s.realtimeModel) return;
|
||||
if (this.saving()) {
|
||||
// 게임(발로란트 메뉴 등)이 아직 켜져 있으면 정밀 변환은 대기열에서 게임이 꺼질 때까지 기다린다
|
||||
const rows = this.store.realtimeUtterancesInRange(from, to);
|
||||
log.info(`경기 종료: ${rows.length}개 발화의 정밀 변환은 게임을 끈 뒤에`);
|
||||
for (const r of rows) this.enqueue(r.id, 'precise', 10);
|
||||
return;
|
||||
}
|
||||
if (this.status.slots.precise.state !== 'loaded') await this.load('precise', s.preciseModel);
|
||||
if (this.status.slots.precise.state !== 'loaded') return;
|
||||
const rows = this.store.realtimeUtterancesInRange(from, to);
|
||||
@@ -232,6 +281,11 @@ export class SttPipeline {
|
||||
|
||||
private pickSlot(job: Job): Slot | null {
|
||||
const { realtime, precise } = this.status.slots;
|
||||
if (this.saving()) {
|
||||
// 게임 중: 정밀 변환은 기다리고, 새 발화는 실시간 모델로만
|
||||
if (job.slot === 'precise') return null;
|
||||
return realtime.state === 'loaded' ? 'realtime' : null;
|
||||
}
|
||||
if (job.slot === 'precise') return precise.state === 'loaded' ? 'precise' : null;
|
||||
// 경기 밖이고 정밀 모델이 올라와 있으면 처음부터 정밀 모델로
|
||||
if (!this.inMatch && precise.state === 'loaded' && this.queue.length < 20) return 'precise';
|
||||
@@ -255,6 +309,7 @@ export class SttPipeline {
|
||||
this.busy = true;
|
||||
this.processing = job.id;
|
||||
this.status.processing = job.id;
|
||||
const t0 = Date.now();
|
||||
this.run(job, this.pickSlot(job)!)
|
||||
.catch((e) => log.error('STT 작업 오류', e))
|
||||
.finally(() => {
|
||||
@@ -267,7 +322,9 @@ export class SttPipeline {
|
||||
} catch (e) {
|
||||
log.warn('변환 뒤 처리 실패', e);
|
||||
}
|
||||
setImmediate(() => this.pump());
|
||||
// 게임 중에는 변환한 만큼(최대 3초) 쉬고 다음 발화로: 여러 명이 연달아 말해도 GPU 를 계속 붙잡지 않는다
|
||||
if (this.saving()) setTimeout(() => this.pump(), Math.min(Date.now() - t0, 3000));
|
||||
else setImmediate(() => this.pump());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -324,6 +381,8 @@ export class SttPipeline {
|
||||
target_lufs: s.audio.targetLufs,
|
||||
noise_sensitivity: s.audio.noiseSensitivity,
|
||||
denoise: s.audio.denoise,
|
||||
// 게임 중에는 빔 1 (빔 3 보다 가볍다. 경기 뒤 정밀 모델이 다시 변환한다)
|
||||
...(this.saving() && slot === 'realtime' ? { beam_size: 1 } : {}),
|
||||
},
|
||||
5 * 60000,
|
||||
);
|
||||
|
||||
@@ -23,6 +23,8 @@ const opt = (name: string) => argv.find((a) => a.startsWith(`--${name}=`))?.spli
|
||||
const SMOKE = flag('smoke');
|
||||
|
||||
app.setAppUserModelId('kr.tkrmagid.gvr');
|
||||
// 설정 창은 글자 · 버튼뿐이라 GPU 로 그릴 필요가 없다. 게임 · 브라우저와 GPU 를 나눠 쓰지 않게 끈다 (v1.9.0)
|
||||
app.disableHardwareAcceleration();
|
||||
if (!SMOKE && !app.requestSingleInstanceLock()) {
|
||||
app.quit();
|
||||
process.exit(0);
|
||||
|
||||
@@ -35,6 +35,7 @@ function defaults(): Settings {
|
||||
modelsDir: null,
|
||||
reprocessAfterMatch: true,
|
||||
gameVramReserveMb: 3072,
|
||||
gameSaver: true,
|
||||
},
|
||||
audio: { targetLufs: -18, denoise: false, noiseSensitivity: 0.5, silenceMs: 800, maxUtteranceSec: 30 },
|
||||
dictionary: {
|
||||
|
||||
@@ -184,6 +184,12 @@ export function SttTab() {
|
||||
<div className="warn-text small">⚠ RTX 50 시리즈(Blackwell)에서 int8 계열은 cuBLAS 오류 사례가 있습니다. 문제가 생기면 float16으로 돌려 주세요.</div>
|
||||
)}
|
||||
<ToggleLine label="경기가 끝나면 정밀 모델로 다시 변환" on={s.reprocessAfterMatch} onChange={(v) => save({ stt: { reprocessAfterMatch: v } })} />
|
||||
<ToggleLine
|
||||
label="게임 중 GPU 아끼기"
|
||||
hint="게임이 켜져 있으면 실시간 모델만 가볍게 쉬어 가며 돌리고, 정밀 모델 변환은 게임을 끈 뒤에 합니다"
|
||||
on={s.gameSaver}
|
||||
onChange={(v) => save({ stt: { gameSaver: v } })}
|
||||
/>
|
||||
<Line label="게임용 VRAM 예약" hint="두 게임 중 큰 값 · 실측 후 조정">
|
||||
<NumInput value={s.gameVramReserveMb} min={0} max={24576} step={256} width={90} suffix="MB" onCommit={(n) => save({ stt: { gameVramReserveMb: n } })} />
|
||||
</Line>
|
||||
|
||||
Reference in New Issue
Block a user