; 음성 변환기 설치 프로그램 (Inno Setup 6). 빌드: scripts/build-release.sh 가 만든 dist\payload 를 담는다. ; ISCC.exe installer\VoiceChanger.iss → dist\VoiceChangerSetup.exe ; 하는 일 ; 1. 설치할 폴더를 고르게 한다. Python · 엔진 · 모델 · 설정 · 캐시 · 임시 파일이 모두 그 폴더 안에만 생긴다 ; 2. 그 폴더에 앱 파일을 풀고, 마이크마다 변환 모듈(APO)을 붙인다 (가상 오디오 장치 설치 없음) ; 3. Python · 엔진 · torch(CUDA) · 엔진 기본 모델을 그 폴더 안으로 내려받는다 (scripts\install.ps1, 10~20분) ; 제거할 때는 마이크 설정을 원래대로 되돌리고, 모델 · 녹음까지 지울지 묻는다. #define AppName "음성 변환기" #ifndef AppVersion #define AppVersion "1.0.0" #endif [Setup] AppId={{8C3F2A51-6D0B-4E7A-9F3C-2B5E1D7A4C90} AppName={#AppName} AppVersion={#AppVersion} AppPublisher=voice_copy DefaultDirName={sd}\VoiceChanger DisableDirPage=no DisableProgramGroupPage=yes DirExistsWarning=no AllowUNCPath=no PrivilegesRequired=admin ArchitecturesAllowed=x64compatible ArchitecturesInstallIn64BitMode=x64compatible MinVersion=10.0.19041 OutputDir=..\dist OutputBaseFilename=VoiceChangerSetup Compression=lzma2 SolidCompression=yes WizardStyle=modern UninstallFilesDir={app}\uninstall UninstallDisplayIcon={app}\VoiceChanger.exe UninstallDisplayName={#AppName} [Languages] Name: "ko"; MessagesFile: "compiler:Languages\Korean.isl" [Messages] ko.SelectDirLabel3=음성 변환기를 설치할 폴더를 골라 주세요.%n%nPython · 변환 엔진 · 목소리 모델 · 설정 · 학습 파일 · 캐시가 모두 이 폴더 안에만 저장됩니다. 설치 중에 약 8GB 를 내려받고, 모델을 만들면 더 늘어나므로 15GB 이상 여유가 있는 드라이브를 골라 주세요. ko.DiskSpaceMBLabel=설치 중에 약 8GB 를 더 내려받습니다. 15GB 이상 비어 있는 드라이브를 권합니다. [Tasks] Name: "desktopicon"; Description: "바탕 화면에 바로 가기 만들기"; Flags: unchecked [Files] Source: "secure-dir.ps1"; Flags: dontcopy Source: "..\dist\payload\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs ignoreversion [Icons] Name: "{autoprograms}\{#AppName}"; Filename: "{app}\VoiceChanger.exe"; WorkingDir: "{app}" Name: "{autodesktop}\{#AppName}"; Filename: "{app}\VoiceChanger.exe"; WorkingDir: "{app}"; Tasks: desktopicon [Run] Filename: "{app}\VoiceChanger.exe"; Description: "음성 변환기 실행"; Flags: postinstall nowait skipifsilent unchecked [UninstallRun] Filename: "powershell.exe"; Parameters: "-NoProfile -ExecutionPolicy Bypass -File ""{app}\scripts\mic-apo.ps1"" -Uninstall -Root ""{app}"""; Flags: runhidden waituntilterminated; RunOnceId: "MicApoUninstall" [Code] { 설치 폴더 보안은 secure-dir.ps1 (설치 프로그램에 들어 있고 임시 폴더에 풀어서 관리자 권한으로 실행)이 맡는다. 관리자 권한으로 실행되는 것(설치 폴더 루트의 exe, app\, scripts\, apo\, uninstall\)은 관리자만 고칠 수 있고, 일반 사용자는 데이터 폴더(models · training · datasets · config · cache · env · engine · tools)에만 쓴다. } function SecureDir(const Mode, Dir: String): Integer; begin ExtractTemporaryFile('secure-dir.ps1'); if not Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -ExecutionPolicy Bypass -File "' + ExpandConstant('{tmp}\secure-dir.ps1') + '" -Mode ' + Mode + ' -App "' + Dir + '"', '', SW_HIDE, ewWaitUntilTerminated, Result) then Result := -1; Log('secure-dir ' + Mode + ' exit=' + IntToStr(Result)); end; function PowerShell(const Args: String; const Show: Integer; var Code: Integer): Boolean; begin Result := Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -ExecutionPolicy Bypass ' + Args, ExpandConstant('{app}'), Show, ewWaitUntilTerminated, Code); end; function IsEmptyDir(const Dir: String): Boolean; var F: TFindRec; begin Result := True; if FindFirst(AddBackslash(Dir) + '*', F) then try repeat if (F.Name <> '.') and (F.Name <> '..') then begin Result := False; Exit; end; until not FindNext(F); finally FindClose(F); end; end; { 다른 파일이 들어 있는 폴더에는 설치하지 않는다. 설치 폴더의 권한을 잠그고, 제거할 때 지우기 때문. 이 앱을 이미 설치한 폴더(업데이트)나 비어 있는 · 새 폴더만 받는다. } function NextButtonClick(CurPageID: Integer): Boolean; var Dir: String; begin Result := True; if CurPageID <> wpSelectDir then Exit; Dir := WizardDirValue; if DirExists(Dir) and not IsEmptyDir(Dir) and not FileExists(AddBackslash(Dir) + 'uninstall\unins000.exe') then begin SuppressibleMsgBox('이 폴더에는 이미 다른 파일이 있습니다.' + #13#10 + '비어 있는 폴더나 새 폴더를 골라 주세요. (예: ' + AddBackslash(Dir) + 'VoiceChanger)', mbError, MB_OK, IDOK); Result := False; Exit; end; { 상위 폴더가 일반 사용자 소유면 그 사용자가 설치 폴더를 통째로 다른 것으로 바꿔칠 수 있다 } if SecureDir('CheckParent', Dir) <> 0 then begin SuppressibleMsgBox('이 위치의 상위 폴더는 관리자 소유가 아니라서 설치할 수 없습니다.' + #13#10 + '드라이브 바로 아래(예: C:\VoiceChanger, D:\VoiceChanger)나 Program Files 처럼 관리자가 관리하는 곳을 골라 주세요.', mbError, MB_OK, IDOK); Result := False; end; end; function PrepareToInstall(var NeedsRestart: Boolean): String; var Code: Integer; begin Result := ''; { 다시 설치(업데이트)할 때 오디오 엔진이 쥐고 있는 APO 파일을 바꿀 수 있게 잠깐 오디오 서비스를 멈춘다. 설치 뒤 mic-apo.ps1 이 다시 켠다. } if FileExists(ExpandConstant('{app}\apo\VoiceChangerAPO.dll')) then Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -Command "Stop-Service -Name AudioEndpointBuilder -Force"', '', SW_HIDE, ewWaitUntilTerminated, Code); { 파일을 풀기 전에 설치 폴더를 관리자 소유로 잠근다. 실패하면 설치하지 않는다. } case SecureDir('Prepare', ExpandConstant('{app}')) of 0: ; 10: Result := '이 폴더에는 이미 다른 파일이 있습니다. 비어 있는 폴더나 새 폴더를 골라 주세요.'; 11: Result := '설치 폴더 안에 링크(정션 · 심볼릭 링크)가 있어 안전하게 설치할 수 없습니다. 링크를 지우거나 새 폴더를 골라 주세요.'; else Result := '설치 폴더의 권한을 잠그지 못했습니다. 다른 폴더를 골라 다시 설치해 주세요.'; end; if (Result <> '') and FileExists(ExpandConstant('{app}\apo\VoiceChangerAPO.dll')) then Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -Command "Start-Service Audiosrv"', '', SW_HIDE, ewWaitUntilTerminated, Code); end; procedure CurStepChanged(CurStep: TSetupStep); var Code: Integer; begin if CurStep <> ssPostInstall then Exit; { 데이터 폴더에만 사용자 쓰기 권한을 주고, 관리자 권한으로 실행되는 파일이 잠겼는지 확인한다. 확인이 안 되면 관리자 권한으로 아무것도 실행하지 않는다. } if SecureDir('Finish', ExpandConstant('{app}')) <> 0 then begin Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -Command "Start-Service Audiosrv"', '', SW_HIDE, ewWaitUntilTerminated, Code); SuppressibleMsgBox('설치 폴더의 권한을 확인하지 못해 마이크 연결과 엔진 내려받기를 하지 않았습니다.' + #13#10 + '음성 변환기를 제거한 뒤 다른 폴더(예: C:\VoiceChanger)에 다시 설치해 주세요.', mbError, MB_OK, IDOK); Exit; end; WizardForm.StatusLabel.Caption := '마이크에 변환 모듈을 붙이는 중... (윈도우 소리가 잠깐 끊깁니다)'; if not PowerShell('-File "' + ExpandConstant('{app}\scripts\mic-apo.ps1') + '" -Install -Root "' + ExpandConstant('{app}') + '"', SW_HIDE, Code) or (Code <> 0) then begin Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -Command "Start-Service Audiosrv"', '', SW_HIDE, ewWaitUntilTerminated, Code); SuppressibleMsgBox('마이크에 변환 모듈을 붙이지 못했습니다. 설치가 끝난 뒤 음성 변환기의 "마이크 다시 연결" 을 눌러 주세요.', mbError, MB_OK, IDOK); end; WizardForm.StatusLabel.Caption := 'Python · 변환 엔진 · 기본 모델을 설치 폴더로 내려받는 중... (10~20분, 검은 창에 진행 상황이 나옵니다)'; { 일반 권한(설치를 시작한 사용자)으로 받는다. 관리자 권한으로 사용자 쓰기 폴더(env · engine)의 코드를 돌리지 않게. } if not ExecAsOriginalUser(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'), '-NoProfile -ExecutionPolicy Bypass -File "' + ExpandConstant('{app}\scripts\install.ps1') + '"', ExpandConstant('{app}'), SW_SHOWNORMAL, ewWaitUntilTerminated, Code) or (Code <> 0) then SuppressibleMsgBox('엔진을 내려받지 못했습니다 (인터넷 연결을 확인해 주세요).' + #13#10 + '설치 폴더의 install.bat 을 실행하면 받은 곳부터 이어서 받습니다.', mbError, MB_OK, IDOK); end; procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var App: String; begin { 마이크 되돌리기([UninstallRun])와 설치 파일 지우기가 끝난 뒤 } if CurUninstallStep <> usPostUninstall then Exit; App := ExpandConstant('{app}'); { 설치 중에 내려받은 것들 (설치 파일 목록에 없어서 직접 지운다) } DelTree(App + '\env', True, True, True); DelTree(App + '\engine', True, True, True); DelTree(App + '\tools', True, True, True); DelTree(App + '\cache', True, True, True); DelTree(App + '\app\__pycache__', True, True, True); RemoveDir(App + '\app'); { 사용자가 만든 것은 물어보고 지운다. 조용히 제거할 때는 남겨 둔다 } { 앱이 만든 폴더만 지운다. 설치 폴더 자체는 비어 있을 때만 지운다 (RemoveDir 는 빈 폴더만 지움) } if (not UninstallSilent) and (MsgBox('만든 목소리 모델 · 학습 파일 · 녹음 · 설정도 지울까요?' + #13#10 + '(models, training, datasets, config 폴더)' + #13#10#13#10 + '"아니요" 를 누르면 남겨 둡니다.', mbConfirmation, MB_YESNO) = IDYES) then begin DelTree(App + '\models', True, True, True); DelTree(App + '\training', True, True, True); DelTree(App + '\datasets', True, True, True); DelTree(App + '\config', True, True, True); end; RemoveDir(App + '\models'); RemoveDir(App + '\training'); RemoveDir(App + '\datasets'); RemoveDir(App + '\config'); DeleteFile(App + '\apo\mic-apo.log'); RemoveDir(App + '\apo'); RemoveDir(App); end;