--- a/app.py +++ b/app.py @@ -206,15 +206,29 @@ progress(0.5, 'Using provided reference text. Encoding audio...') else: progress(0.25, 'Transcribing reference audio with Whisper...') + # llasaモデルをCPUに移動してVRAMを解放 VRAMのキャッシュをクリア + print("[VRAM_SWAP] Llasa model moved to CPU.") + model.to("cpu") + torch.cuda.empty_cache() global whisper_turbo_pipe if whisper_turbo_pipe is None: whisper_turbo_pipe = pipeline( "automatic-speech-recognition", - model="openai/whisper-large-v3-turbo", + model="litagin/anime-whisper", torch_dtype=torch.float16, device=device.type, + chunk_length_s=30.0, + batch_size=64, ) + else: + print("[Whisper] Moving Whisper model to CUDA (FP16) for transcription.") + whisper_turbo_pipe.model.to("cuda").half() prompt_text = whisper_turbo_pipe(prompt_wav[0].cpu().numpy())['text'].strip() + # whisperモデルをCPUに移動してVRAMを解放 llasaモデルをCUDAに戻してVRAMのキャッシュをクリア + print("[VRAM_SWAP] Whisper model moved to CPU. Llasa model moved to CUDA") + whisper_turbo_pipe.model.to("cpu").half() + model.to("cuda") + torch.cuda.empty_cache() progress(0.5, 'Transcribed! Encoding reference audio...') # Encode prompt audio to codec tokens