-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathsetup-windows.ps1
More file actions
877 lines (733 loc) Β· 36.7 KB
/
Copy pathsetup-windows.ps1
File metadata and controls
877 lines (733 loc) Β· 36.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
ο»Ώ#
# File: setup-windows.ps1
#
# AgentVibes Windows Native Setup Script
# Installs and configures AgentVibes for Windows
#
# Usage:
# .\setup-windows.ps1 # Interactive setup
# .\setup-windows.ps1 -Provider soprano # Skip provider prompt
#
param(
[Parameter(Mandatory = $false)]
[ValidateSet('soprano', 'piper', 'sapi')]
[string]$Provider
)
$ErrorActionPreference = "Stop"
# ββ UI Helper Functions βββββββββββββββββββββββββββββββββββββ
$BoxWidth = 58
function Write-BoxTop {
Write-Host " $([char]0x256D)$([string]::new([char]0x2500, $BoxWidth))$([char]0x256E)" -ForegroundColor Cyan
}
function Write-BoxBottom {
Write-Host " $([char]0x2570)$([string]::new([char]0x2500, $BoxWidth))$([char]0x256F)" -ForegroundColor Cyan
}
function Write-BoxLine([string]$text, [string]$color = "White") {
$padding = $BoxWidth - $text.Length
if ($padding -lt 0) { $padding = 0; $text = $text.Substring(0, $BoxWidth) }
Write-Host " $([char]0x2502)" -ForegroundColor Cyan -NoNewline
Write-Host "$text$([string]::new(' ', $padding))" -ForegroundColor $color -NoNewline
Write-Host "$([char]0x2502)" -ForegroundColor Cyan
}
function Write-BoxEmpty {
Write-BoxLine ([string]::new(' ', $BoxWidth)) "White"
}
function Write-Section([string]$label) {
Write-Host ""
Write-Host " $([string]::new([char]0x2501, 56))" -ForegroundColor Yellow
Write-Host " $label" -ForegroundColor Yellow
Write-Host " $([string]::new([char]0x2501, 56))" -ForegroundColor Yellow
Write-Host ""
}
function Write-Ok([string]$text) {
Write-Host " [OK] $text" -ForegroundColor Green
}
function Write-Warn([string]$text) {
Write-Host " [!!] $text" -ForegroundColor Yellow
}
function Write-Err([string]$text) {
Write-Host " [XX] $text" -ForegroundColor Red
}
function Write-Info([string]$text) {
Write-Host " $text" -ForegroundColor Gray
}
function Write-Item([string]$icon, [string]$name, [string]$desc) {
$nameWidth = 30
$paddedName = $name.PadRight($nameWidth)
Write-Host " $icon " -ForegroundColor Green -NoNewline
Write-Host $paddedName -ForegroundColor White -NoNewline
Write-Host $desc -ForegroundColor DarkGray
}
# Non-Destructive Configuration Rule (CLAUDE.md): setup must never clobber a
# user-config value the Node installer deliberately preserves across re-runs.
# Writes the value ONLY when the file is absent; otherwise keeps the existing
# choice and reports it. Pass -Force for the rare case where an overwrite is
# genuinely intended.
function Set-ConfigValueSafe {
param(
[Parameter(Mandatory)][string]$Path,
[Parameter(Mandatory)][AllowEmptyString()][string]$Value,
[string]$Label = (Split-Path $Path -Leaf),
[switch]$Force
)
if ((Test-Path $Path) -and -not $Force) {
$current = (Get-Content -Path $Path -Raw -ErrorAction SilentlyContinue)
if ($null -ne $current) { $current = $current.Trim() }
Write-Info "Keeping existing $Label ($current)"
return
}
Set-Content -Path $Path -Value $Value -NoNewline
}
# For values driven by an interactive prompt: honor the user's EXPLICIT answer
# (non-empty $RawInput) this run, but if they just pressed Enter to accept the
# default β or the prompt was skipped entirely (e.g. ffmpeg missing) β keep any
# existing value rather than silently overwriting it with the default. This
# resolves the bug where the script printed the user's new choice yet wrote the
# default: honor real input, preserve config on blind-Enter / skipped prompts.
function Set-ConfigFromChoice {
param(
[Parameter(Mandatory)][string]$Path,
[Parameter(Mandatory)][AllowEmptyString()][string]$Value,
[Parameter(Mandatory)][AllowEmptyString()][string]$RawInput,
[string]$Label = (Split-Path $Path -Leaf)
)
if ([string]::IsNullOrWhiteSpace($RawInput) -and (Test-Path $Path)) {
$current = (Get-Content -Path $Path -Raw -ErrorAction SilentlyContinue)
if ($null -ne $current) { $current = $current.Trim() }
Write-Info "Keeping existing $Label ($current)"
return
}
Set-Content -Path $Path -Value $Value -NoNewline
}
# ββ Read Version ββββββββββββββββββββββββββββββββββββββββββββ
$Version = "unknown"
$ScriptDir = $PSScriptRoot
$PackageJson = Join-Path $ScriptDir "package.json"
if (Test-Path $PackageJson) {
try {
$pkg = Get-Content $PackageJson -Raw | ConvertFrom-Json
$Version = $pkg.version
} catch {}
}
# ββ Banner ββββββββββββββββββββββββββββββββββββββββββββββββββ
# ANSI Shadow figlet art matching the Node.js installer
$AgentArt = @(
" ββββββ βββββββ ββββββββββββ ββββββββββββ",
"ββββββββββββββββ βββββββββββββ ββββββββββββ",
"βββββββββββ ββββββββββ ββββββ βββ βββ ",
"βββββββββββ βββββββββ ββββββββββ βββ ",
"βββ βββββββββββββββββββββββ ββββββ βββ ",
"βββ βββ βββββββ βββββββββββ βββββ βββ "
)
$VibesArt = @(
"βββ βββββββββββββ ββββββββββββββββ",
"βββ ββββββββββββββββββββββββββββββ",
"βββ ββββββββββββββββββββ ββββββββ",
"ββββ βββββββββββββββββββββ ββββββββ",
" βββββββ βββββββββββββββββββββββββββ",
" βββββ ββββββββββ ββββββββββββββββ"
)
Write-Host ""
for ($i = 0; $i -lt $AgentArt.Count; $i++) {
Write-Host $AgentArt[$i] -ForegroundColor Cyan -NoNewline
Write-Host " " -NoNewline
Write-Host $VibesArt[$i] -ForegroundColor Magenta
}
Write-Host ""
Write-BoxTop
Write-BoxEmpty
Write-BoxLine " Windows Native Setup v$Version" "Cyan"
Write-BoxEmpty
Write-BoxLine " Now your AI Agents can finally talk back!" "White"
Write-BoxLine " Professional TTS for Claude Code on Windows" "DarkGray"
Write-BoxEmpty
Write-BoxLine " https://agentvibes.org" "DarkCyan"
Write-BoxBottom
Write-Host ""
# ββ What's New ββββββββββββββββββββββββββββββββββββββββββββββ
Write-Host " WHAT'S NEW in v$Version" -ForegroundColor Green
Write-Host ""
Write-Host " Native Windows support with three TTS providers (Soprano neural," -ForegroundColor Cyan
Write-Host " Piper offline, Windows SAPI), background music from 16 genre tracks," -ForegroundColor Cyan
Write-Host " reverb effects via ffmpeg, and verbosity control." -ForegroundColor Cyan
Write-Host ""
Write-Host " Thanks to @nathanchase (Soprano), @alexeyv (Windows SAPI)," -ForegroundColor Yellow
Write-Host " @bmadcode (BMAD Method)!" -ForegroundColor Yellow
Write-Host ""
Write-Host " KEY HIGHLIGHTS:" -ForegroundColor Green
Write-Host " [*] Native Windows TTS - Soprano, Piper, SAPI. No WSL needed!" -ForegroundColor Gray
Write-Host " [*] Background Music - 16 genre tracks (Bachata, Flamenco, etc.)" -ForegroundColor Gray
Write-Host " [*] Reverb & Effects - 5 reverb levels via ffmpeg aecho filter" -ForegroundColor Gray
Write-Host " [*] Verbosity Control - High, Medium, or Low transparency" -ForegroundColor Gray
Write-Host " [*] Beautiful Installer - Figlet banner, provider detection" -ForegroundColor Gray
Write-Host " [*] 93/93 Tests Passing - 46 Windows + 47 cross-platform" -ForegroundColor Gray
Write-Host ""
# ββ Node.js Detection ββββββββββββββββββββββββββββββββββββββ
try {
$nodeVersion = & node --version 2>$null
if ($nodeVersion) {
Write-Host " Node.js detected " -ForegroundColor Gray -NoNewline
Write-Host "($nodeVersion)" -ForegroundColor Green
Write-Host ""
Write-Host " Tip: For a richer install experience, you can also run:" -ForegroundColor DarkGray
Write-Host " npx agentvibes install" -ForegroundColor Cyan
Write-Host ""
$choice = Read-Host " Launch the Node.js installer instead? (y/N)"
if ($choice -eq 'y' -or $choice -eq 'Y') {
Write-Host ""
Write-Host " Launching Node.js installer..." -ForegroundColor Cyan
Write-Host ""
$installerPath = Join-Path $ScriptDir "src\installer.js"
if (Test-Path $installerPath) {
& node $installerPath install
} else {
& npx agentvibes install
}
exit 0
}
Write-Host ""
Write-Host " Continuing with PowerShell installer..." -ForegroundColor Gray
}
} catch {}
# ββ PowerShell Version Check βββββββββββββββββββββββββββββββ
Write-Section "System Check"
$PSVersionRequired = [Version]"5.1"
if ($PSVersionTable.PSVersion -lt $PSVersionRequired) {
Write-Err "PowerShell 5.1+ required (found $($PSVersionTable.PSVersion))"
exit 1
}
Write-Ok "PowerShell $($PSVersionTable.PSVersion)"
# ββ Detect Project Root βββββββββββββββββββββββββββββββββββββ
if ($ScriptDir -match '[\\/]node_modules[\\/]agentvibes$') {
$ProjectRoot = (Resolve-Path (Join-Path $ScriptDir "..\..")).Path
Write-Ok "Detected npm package in: $ProjectRoot"
} else {
$ProjectRoot = $ScriptDir
Write-Ok "Project root: $ProjectRoot"
}
# ββ Setup Directories βββββββββββββββββββββββββββββββββββββββ
Write-Section "Setting Up Directories"
Write-Host " These directories store AgentVibes config and data:" -ForegroundColor Gray
Write-Host ""
$ProjectClaudeDir = "$ProjectRoot\.claude"
$HooksDir = "$ProjectClaudeDir\hooks-windows"
$UserClaudeDir = "$env:USERPROFILE\.claude"
$AudioDir = "$UserClaudeDir\audio"
$VoicesDir = "$UserClaudeDir\piper-voices"
$PiperDir = "$env:LOCALAPPDATA\Programs\Piper"
$PiperExe = "$PiperDir\piper.exe"
# Directory info: path, description, category
$DirInfo = @(
@{ Path = $ProjectClaudeDir; Desc = "Project settings and hooks config"; Cat = "Project" },
@{ Path = $HooksDir; Desc = "PowerShell TTS hook scripts"; Cat = "Project" },
@{ Path = $UserClaudeDir; Desc = "Global AgentVibes configuration"; Cat = "User Profile" },
@{ Path = $AudioDir; Desc = "TTS audio file cache"; Cat = "User Profile" },
@{ Path = $VoicesDir; Desc = "Piper voice model files"; Cat = "User Profile" },
@{ Path = $PiperDir; Desc = "Piper TTS engine binary"; Cat = "Applications" }
)
$CurrentCat = ""
foreach ($entry in $DirInfo) {
if ($entry.Cat -ne $CurrentCat) {
if ($CurrentCat -ne "") { Write-Host "" }
Write-Host " $($entry.Cat)" -ForegroundColor Cyan
$CurrentCat = $entry.Cat
}
$dir = $entry.Path
$existed = Test-Path $dir
if (-not $existed) {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
}
# Show relative path where possible
$displayPath = $dir
if ($dir.StartsWith($ProjectRoot)) {
$displayPath = $dir.Substring($ProjectRoot.Length + 1)
} elseif ($dir.StartsWith($env:USERPROFILE)) {
$displayPath = "~" + $dir.Substring($env:USERPROFILE.Length)
} elseif ($dir.StartsWith($env:LOCALAPPDATA)) {
$displayPath = "%LOCALAPPDATA%" + $dir.Substring($env:LOCALAPPDATA.Length)
}
$status = if ($existed) { "[OK]" } else { "[OK]" }
$action = if ($existed) { "exists" } else { "created" }
Write-Host " $status " -ForegroundColor Green -NoNewline
Write-Host $displayPath.PadRight(32) -ForegroundColor White -NoNewline
Write-Host $entry.Desc -ForegroundColor DarkGray
}
# ββ Install Hook Scripts ββββββββββββββββββββββββββββββββββββ
Write-Section "Installing TTS Scripts"
Write-Host " These scripts enable Claude Code to speak on Windows:" -ForegroundColor Gray
Write-Host ""
$SourceHooksDir = Join-Path $ScriptDir ".claude\hooks-windows"
# Validate source path is within the script directory (path traversal prevention)
$ResolvedSource = (Resolve-Path -Path $SourceHooksDir -ErrorAction SilentlyContinue).Path
$ResolvedScript = (Resolve-Path -Path $ScriptDir).Path
if (-not $ResolvedSource -or -not $ResolvedSource.StartsWith($ResolvedScript)) {
Write-Err "Hook scripts source path is outside the project directory"
exit 1
}
if (-not (Test-Path $SourceHooksDir)) {
Write-Err "Hook scripts not found at: $SourceHooksDir"
Write-Info "Make sure you're running this from the AgentVibes project directory"
exit 1
}
# Ensure destination hooks directory exists
if (-not (Test-Path $HooksDir)) {
New-Item -ItemType Directory -Path $HooksDir -Force | Out-Null
}
# Friendly descriptions for the well-known scripts; any other *.ps1 in the
# source dir still gets installed (with a generic label) rather than dropped.
$HookDescriptions = @{
"play-tts.ps1" = "Main TTS router - dispatches to active provider"
"play-tts-soprano.ps1" = "Soprano neural voice provider (fastest)"
"play-tts-windows-piper.ps1" = "Piper offline neural voice provider"
"play-tts-windows-sapi.ps1" = "Windows built-in SAPI voice provider"
"provider-manager.ps1" = "Switch between TTS providers"
"voice-manager-windows.ps1" = "Browse and select voice models"
"audio-cache-utils.ps1" = "Manage TTS audio file cache"
"session-start-tts.ps1" = "Auto-activates TTS when Claude starts"
}
# One timestamp per run so this run's backups group together and never collide.
$BackupStamp = (Get-Date -Format 'yyyyMMdd-HHmmss')
# Copy EVERY hook script, not a hand-maintained whitelist β a partial list
# produced mixed-generation installs (new router + stale providers/watcher).
$CopiedCount = 0
foreach ($SourceFile in (Get-ChildItem -Path $SourceHooksDir -Filter *.ps1 -File)) {
$script = $SourceFile.Name
$DestFile = Join-Path $HooksDir $script
$desc = if ($HookDescriptions.ContainsKey($script)) { $HookDescriptions[$script] } else { "AgentVibes hook script" }
# Skip if source and destination are the same file (running from project root)
$resolvedSrc = $SourceFile.FullName
$resolvedDst = if (Test-Path $DestFile) { (Resolve-Path $DestFile).Path } else { "" }
if ($resolvedSrc -eq $resolvedDst) {
Write-Item "[OK]" $script $desc
$CopiedCount++
continue
}
# Non-Destructive rule: back up an existing, differing file before overwrite
# so a user-modified hook is always recoverable (timestamped, every run).
if (Test-Path $DestFile) {
$srcHash = (Get-FileHash -Path $resolvedSrc -Algorithm SHA256).Hash
$dstHash = (Get-FileHash -Path $DestFile -Algorithm SHA256).Hash
if ($srcHash -ne $dstHash) {
Copy-Item -Path $DestFile -Destination "$DestFile.user.bak.$BackupStamp" -ErrorAction SilentlyContinue
}
}
Copy-Item -Path $SourceFile.FullName -Destination $DestFile -Force
Write-Item "[OK]" $script $desc
$CopiedCount++
}
if ($CopiedCount -eq 0) {
Write-Err "No hook scripts were installed"
exit 1
}
Write-Host ""
Write-Host " Location: " -ForegroundColor Gray -NoNewline
Write-Host ".claude\hooks-windows\" -ForegroundColor Cyan
Write-Ok "Installed $CopiedCount TTS scripts"
# ββ Provider Selection ββββββββββββββββββββββββββββββββββββββ
Write-Section "Choose Your TTS Provider"
# Check if pip is available
$PipAvailable = $false
try {
$pipTest = & pip --version 2>$null
if ($pipTest) { $PipAvailable = $true }
} catch {}
# Check Soprano availability
$SopranoAvailable = $false
try {
$response = Invoke-WebRequest -Uri "http://127.0.0.1:7860/api/predict" `
-Method POST -UseBasicParsing -TimeoutSec 2 `
-ContentType "application/json" `
-Body '{"data":["test",1.0],"fn_index":0}' `
-ErrorAction SilentlyContinue
if ($response.StatusCode -eq 200) { $SopranoAvailable = $true }
} catch {}
# Check if pip has soprano-tts (only if pip is available)
$SopranoInstalled = $false
if ($PipAvailable) {
try {
$pipResult = & pip show soprano-tts 2>$null
if ($pipResult) { $SopranoInstalled = $true }
} catch {}
}
if (-not $Provider) {
Write-Host " [1] Soprano (Best Quality)" -ForegroundColor White
Write-Host " Ultra-fast neural TTS, 80M parameter model" -ForegroundColor DarkGray
if ($SopranoAvailable) {
Write-Host " Status: " -ForegroundColor DarkGray -NoNewline
Write-Host "Running on port 7860" -ForegroundColor Green
} elseif ($SopranoInstalled) {
Write-Host " Status: " -ForegroundColor DarkGray -NoNewline
Write-Host "Installed (not running)" -ForegroundColor Yellow
} else {
Write-Host " Requires: pip install soprano-tts" -ForegroundColor DarkGray
}
Write-Host ""
Write-Host " [2] Piper (Recommended Offline)" -ForegroundColor White
Write-Host " High quality neural voices, works fully offline" -ForegroundColor DarkGray
if (Test-Path $PiperExe) {
Write-Host " Status: " -ForegroundColor DarkGray -NoNewline
Write-Host "Installed" -ForegroundColor Green
} else {
Write-Host " Downloads: ~100MB (piper.exe + voice model)" -ForegroundColor DarkGray
}
Write-Host ""
Write-Host " [3] Windows SAPI (Zero Setup)" -ForegroundColor White
Write-Host " Built-in Windows voices (David, Zira, Mark)" -ForegroundColor DarkGray
Write-Host " No download required" -ForegroundColor DarkGray
Write-Host ""
$choice = Read-Host " Enter choice (1-3, default: 1)"
switch ($choice) {
"2" { $Provider = "piper" }
"3" { $Provider = "sapi" }
default { $Provider = "soprano" }
}
}
$ProviderDisplayName = switch ($Provider) {
"soprano" { "Soprano TTS" }
"piper" { "Piper TTS" }
"sapi" { "Windows SAPI" }
}
Write-Host ""
Write-Ok "Selected: $ProviderDisplayName"
# ββ Install Soprano if selected βββββββββββββββββββββββββββββ
if ($Provider -eq "soprano") {
Write-Section "Soprano Setup"
if ($SopranoAvailable) {
Write-Ok "Soprano server running on port 7860"
} elseif ($SopranoInstalled) {
Write-Warn "Soprano is installed but not running"
Write-Info "Start it with: soprano-tts --share"
Write-Info "Or run it in WSL and forward port 7860"
} else {
Write-Warn "Soprano TTS not detected"
Write-Host ""
if (-not $PipAvailable) {
Write-Error "pip is not available on this system"
Write-Info "Please install Python 3 with pip, then run:"
Write-Host " pip install soprano-tts" -ForegroundColor Cyan
Write-Host ""
} else {
# Offer to install Soprano
$installChoice = Read-Host "Would you like to install Soprano now? (y/n, default: y)"
if ($installChoice -eq "" -or $installChoice -eq "y" -or $installChoice -eq "Y") {
Write-Info "Installing Soprano TTS..."
Write-Host ""
try {
& pip install soprano-tts 2>&1 | Tee-Object -Variable pipOutput | Write-Host
# Re-check if installation succeeded
$SopranoInstalled = $false
try {
$pipResult = & pip show soprano-tts 2>$null
if ($pipResult) { $SopranoInstalled = $true }
} catch {}
if ($SopranoInstalled) {
Write-Ok "Soprano TTS installed successfully!"
Write-Info "Start it with: soprano-tts --share"
} else {
Write-Error "Installation may have failed. Please check the output above."
Write-Info "You can try installing manually: pip install soprano-tts"
}
} catch {
Write-Error "Installation failed: $_"
Write-Info "Please install manually: pip install soprano-tts"
}
} else {
Write-Host ""
Write-Host " To install Soprano manually:" -ForegroundColor White
Write-Host " pip install soprano-tts" -ForegroundColor Cyan
Write-Host ""
Write-Host " Or use Soprano in WSL with port forwarding:" -ForegroundColor White
Write-Host " ssh -L 7860:localhost:7860 your-wsl-host" -ForegroundColor Cyan
Write-Host ""
Write-Info "AgentVibes will work once Soprano is accessible on port 7860"
}
}
}
}
# ββ Install Piper if selected βββββββββββββββββββββββββββββββ
if ($Provider -eq "piper") {
Write-Section "Piper Installation"
if (Test-Path $PiperExe) {
Write-Ok "Piper already installed at: $PiperDir"
}
else {
Write-Host " Downloading Piper TTS engine from GitHub..." -ForegroundColor White
$DownloadUrl = "https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_windows_amd64.zip"
$DownloadFile = "$env:TEMP\piper-windows.zip"
try {
Write-Info $DownloadUrl
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $DownloadUrl -OutFile $DownloadFile -UseBasicParsing -ErrorAction Stop
Write-Ok "Downloaded ($('{0:N2}' -f ((Get-Item $DownloadFile).Length / 1MB)) MB)"
Write-Host " Extracting..." -ForegroundColor Gray
$TempExtractDir = "$env:TEMP\piper-extract"
Remove-Item -Path $TempExtractDir -Recurse -Force -ErrorAction SilentlyContinue
Expand-Archive -Path $DownloadFile -DestinationPath $TempExtractDir -Force
# Find piper.exe recursively
$PiperFound = Get-ChildItem -Path $TempExtractDir -Name "piper.exe" -Recurse
if ($PiperFound) {
$PiperExePath = (Get-ChildItem -Path $TempExtractDir -Filter "piper.exe" -Recurse).FullName | Select-Object -First 1
$PiperSourceDir = Split-Path -Parent $PiperExePath
Copy-Item -Path "$PiperSourceDir\*" -Destination $PiperDir -Recurse -Force
if (Test-Path $PiperExe) {
Write-Ok "Piper installed to: $PiperDir"
}
else {
throw "Failed to copy Piper executable"
}
}
else {
throw "piper.exe not found in extracted files"
}
# Cleanup
Remove-Item -Path $TempExtractDir -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $DownloadFile -Force -ErrorAction SilentlyContinue
}
catch {
Write-Err "Failed to install Piper: $_"
Write-Info "Please check your internet connection and try again"
exit 1
}
}
# Download default voice
Write-Host ""
Write-Host " Setting up default voice model..." -ForegroundColor White
$DefaultVoice = "en_US-ryan-high"
$VoiceDir = $VoicesDir
if ((Test-Path "$VoiceDir\$DefaultVoice.onnx") -and (Test-Path "$VoiceDir\$DefaultVoice.onnx.json")) {
Write-Ok "Default voice ($DefaultVoice) already downloaded"
}
else {
Write-Host " Downloading $DefaultVoice..." -ForegroundColor Gray
try {
$HFBase = "https://huggingface.co/rhasspy/piper-voices/resolve/main/en/en_US/ryan/high"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Write-Host " Downloading model file..." -ForegroundColor Gray
Invoke-WebRequest -Uri "$HFBase/$DefaultVoice.onnx" `
-OutFile "$VoiceDir\$DefaultVoice.onnx" `
-UseBasicParsing -ErrorAction Stop
Write-Host " Downloading config file..." -ForegroundColor Gray
Invoke-WebRequest -Uri "$HFBase/$DefaultVoice.onnx.json" `
-OutFile "$VoiceDir\$DefaultVoice.onnx.json" `
-UseBasicParsing -ErrorAction Stop
Write-Ok "Voice model downloaded: $DefaultVoice"
}
catch {
Write-Warn "Could not download voice: $_"
Write-Info "You can download voices manually later"
}
}
}
# ββ Set Active Provider βββββββββββββββββββββββββββββββββββββ
Write-Section "Configuring Provider"
$ProviderFile = "$ProjectClaudeDir\tts-provider.txt"
$ProviderName = switch ($Provider) {
"soprano" { "soprano" }
"piper" { "windows-piper" }
"sapi" { "windows-sapi" }
}
Set-Content -Path $ProviderFile -Value $ProviderName -NoNewline
Write-Ok "Active provider set to: $ProviderName"
Write-Info "Config file: .claude\tts-provider.txt"
# ββ Background Music Selection βββββββββββββββββββββββββ
Write-Section "Background Music"
Write-Host " Play background music under TTS voice output?" -ForegroundColor Gray
Write-Host " Requires ffmpeg (mixing voice + music)." -ForegroundColor DarkGray
Write-Host ""
# Check ffmpeg availability
$HasFfmpeg = $false
try {
$null = Get-Command ffmpeg -ErrorAction Stop
$HasFfmpeg = $true
} catch {}
$BgMusicEnabled = $false
$BgMusicTrack = "agent_vibes_bachata_v1_loop.mp3"
$BgMusicDisplayName = "Off"
$bgChoice = "" # user's raw answer to the enable prompt ('' = skipped/default)
$trackChoice = "" # user's raw answer to the track prompt ('' = skipped/default)
if (-not $HasFfmpeg) {
Write-Warn "ffmpeg not found - background music requires ffmpeg"
Write-Info "Install ffmpeg and re-run setup to enable background music"
} else {
Write-Host " [1] Yes - Enable background music (Recommended)" -ForegroundColor White
Write-Host " [2] No - Voice only" -ForegroundColor White
Write-Host ""
$bgChoice = Read-Host " Enter choice (1-2, default: 1)"
if ($bgChoice -eq "2") {
$BgMusicEnabled = $false
$BgMusicDisplayName = "Off"
Write-Host ""
Write-Ok "Background music: Disabled"
} else {
$BgMusicEnabled = $true
# Track list with filenames and display info
$Tracks = @(
@{ File = "agentvibes_soft_flamenco_loop.mp3"; Name = "Soft Flamenco"; Desc = "Spanish guitar" },
@{ File = "agent_vibes_bachata_v1_loop.mp3"; Name = "Bachata"; Desc = "Latin rhythm" },
@{ File = "agent_vibes_bossa_nova_v2_loop.mp3"; Name = "Bossa Nova"; Desc = "Brazilian jazz" },
@{ File = "agent_vibes_salsa_v2_loop.mp3"; Name = "Salsa"; Desc = "Latin dance" },
@{ File = "agent_vibes_cumbia_v1_loop.mp3"; Name = "Cumbia"; Desc = "Colombian folk" },
@{ File = "agent_vibes_japanese_city_pop_v1_loop.mp3"; Name = "Japanese City Pop"; Desc = "80s synth" },
@{ File = "agent_vibes_chillwave_v2_loop.mp3"; Name = "Chillwave"; Desc = "Electronic ambient" },
@{ File = "dreamy_house_loop.mp3"; Name = "Dreamy House"; Desc = "Electronic dance" },
@{ File = "agent_vibes_dark_chill_step_loop.mp3"; Name = "Dark Chill Step"; Desc = "Electronic bass" },
@{ File = "agent_vibes_goa_trance_v2_loop.mp3"; Name = "Goa Trance"; Desc = "Psychedelic electronic" },
@{ File = "agent_vibes_harpsichord_v2_loop.mp3"; Name = "Harpsichord"; Desc = "Baroque classical" },
@{ File = "agent_vibes_celtic_harp_v1_loop.mp3"; Name = "Celtic Harp"; Desc = "Irish traditional" },
@{ File = "agent_vibes_hawaiian_slack_key_guitar_v2_loop.mp3"; Name = "Hawaiian Slack Key"; Desc = "Island guitar" },
@{ File = "agent_vibes_arabic_v2_loop.mp3"; Name = "Arabic Oud"; Desc = "Middle Eastern" },
@{ File = "agent_vibes_ganawa_ambient_v2_loop.mp3"; Name = "Gnawa Ambient"; Desc = "North African" },
@{ File = "agent_vibes_tabla_dream_pop_v1_loop.mp3"; Name = "Tabla Dream Pop"; Desc = "Indian percussion" }
)
Write-Host ""
Write-Host " Choose a background music genre:" -ForegroundColor White
Write-Host ""
for ($i = 0; $i -lt $Tracks.Count; $i++) {
$num = ($i + 1).ToString().PadLeft(2)
$trackName = $Tracks[$i].Name.PadRight(22)
Write-Host " [$num] " -ForegroundColor White -NoNewline
Write-Host $trackName -ForegroundColor Cyan -NoNewline
Write-Host $Tracks[$i].Desc -ForegroundColor DarkGray
}
Write-Host ""
$trackChoice = Read-Host " Enter choice (1-16, default: 2)"
$trackIndex = 1 # default to Bachata (index 1)
if ($trackChoice -match '^\d+$') {
$parsed = [int]$trackChoice
if ($parsed -ge 1 -and $parsed -le $Tracks.Count) {
$trackIndex = $parsed - 1
}
}
$BgMusicTrack = $Tracks[$trackIndex].File
$BgMusicDisplayName = $Tracks[$trackIndex].Name
Write-Host ""
Write-Ok "Background music: $BgMusicDisplayName"
}
}
# Write background music config
$ConfigDir = "$ProjectClaudeDir\config"
if (-not (Test-Path $ConfigDir)) {
New-Item -ItemType Directory -Path $ConfigDir -Force | Out-Null
}
$bgEnabledValue = if ($BgMusicEnabled) { "true" } else { "false" }
# Honor the user's explicit answers this run; preserve existing config when the
# prompt was skipped (no ffmpeg) or accepted by pressing Enter.
Set-ConfigFromChoice -Path "$ConfigDir\background-music-enabled.txt" -Value $bgEnabledValue -RawInput $bgChoice -Label "background music enabled"
Set-ConfigFromChoice -Path "$ConfigDir\background-music-default.txt" -Value $BgMusicTrack -RawInput $trackChoice -Label "background music track"
# Volume is not interactively prompted (hardcoded 20% per project rule; full
# sweep in AVI-S8.4) β preserve a user's custom volume across re-runs.
Set-ConfigValueSafe -Path "$ConfigDir\background-music-volume.txt" -Value "0.20" -Label "background music volume"
# ββ Audio Effects (Reverb) βββββββββββββββββββββββββββββ
Write-Section "Audio Effects"
Write-Host " Add reverb effect to voice output?" -ForegroundColor Gray
Write-Host ""
$ReverbLevel = "off"
$ReverbDisplayName = "Off"
if (-not $HasFfmpeg) {
Write-Warn "ffmpeg not found - reverb requires ffmpeg"
Write-Info "Install ffmpeg and re-run setup to enable reverb"
} else {
Write-Host " [1] Off Dry, no reverb" -ForegroundColor White
Write-Host " [2] Light Small room (Recommended)" -ForegroundColor White
Write-Host " [3] Medium Conference room" -ForegroundColor White
Write-Host " [4] Heavy Large hall" -ForegroundColor White
Write-Host " [5] Cathedral Epic space" -ForegroundColor White
Write-Host ""
$reverbChoice = Read-Host " Enter choice (1-5, default: 2)"
switch ($reverbChoice) {
"1" { $ReverbLevel = "off"; $ReverbDisplayName = "Off" }
"3" { $ReverbLevel = "medium"; $ReverbDisplayName = "Medium" }
"4" { $ReverbLevel = "heavy"; $ReverbDisplayName = "Heavy" }
"5" { $ReverbLevel = "cathedral"; $ReverbDisplayName = "Cathedral" }
default { $ReverbLevel = "light"; $ReverbDisplayName = "Light" }
}
Write-Host ""
Write-Ok "Reverb: $ReverbDisplayName"
}
# Write reverb config β honor an explicit choice; preserve existing on skip/Enter.
# ($reverbChoice is unset when the prompt was skipped for missing ffmpeg.)
if (-not (Get-Variable -Name reverbChoice -ErrorAction SilentlyContinue)) { $reverbChoice = "" }
Set-ConfigFromChoice -Path "$ConfigDir\reverb-level.txt" -Value $ReverbLevel -RawInput $reverbChoice -Label "reverb level"
# ββ Verbosity / Transparency ββββββββββββββββββββββββββ
Write-Section "TTS Verbosity"
Write-Host " How much should Claude speak during interactions?" -ForegroundColor Gray
Write-Host ""
Write-Host " [1] High Full reasoning, decisions, trade-offs" -ForegroundColor White
Write-Host " [2] Medium Key updates and acknowledgments" -ForegroundColor White
Write-Host " [3] Low Only essential messages" -ForegroundColor White
Write-Host ""
$verbChoice = Read-Host " Enter choice (1-3, default: 1)"
$VerbosityLevel = "high"
$VerbosityDisplayName = "High"
switch ($verbChoice) {
"2" { $VerbosityLevel = "medium"; $VerbosityDisplayName = "Medium" }
"3" { $VerbosityLevel = "low"; $VerbosityDisplayName = "Low" }
default { $VerbosityLevel = "high"; $VerbosityDisplayName = "High" }
}
Write-Host ""
Write-Ok "Verbosity: $VerbosityDisplayName"
# Write verbosity config β verbosity is always prompted, so honor the answer;
# preserve existing only when the user pressed Enter to accept the default.
Set-ConfigFromChoice -Path "$ProjectClaudeDir\tts-verbosity.txt" -Value $VerbosityLevel -RawInput $verbChoice -Label "TTS verbosity"
# ββ Test TTS ββββββββββββββββββββββββββββββββββββββββββββββββ
Write-Section "Testing TTS"
Write-Host " Running a quick TTS test..." -ForegroundColor Gray
Write-Host ""
$TestMessage = "Agent Vibes here. Setup complete, ready to speak on Windows."
try {
switch ($Provider) {
"soprano" {
if ($SopranoAvailable) {
& "$HooksDir\play-tts-soprano.ps1" $TestMessage | Out-Null
Write-Ok "Soprano TTS is working"
} else {
Write-Warn "Soprano not running - skipping audio test"
Write-Info "Start Soprano, then test with:"
Write-Info ".\.claude\hooks-windows\play-tts.ps1 'Hello'"
}
}
"piper" {
& "$HooksDir\play-tts-windows-piper.ps1" $TestMessage | Out-Null
Write-Ok "Piper TTS is working"
}
"sapi" {
& "$HooksDir\play-tts-windows-sapi.ps1" $TestMessage | Out-Null
Write-Ok "Windows SAPI is working"
}
}
}
catch {
Write-Warn "TTS test failed: $_"
Write-Info "AgentVibes should still work - check troubleshooting in WINDOWS-SETUP.md"
}
# ββ Completion ββββββββββββββββββββββββββββββββββββββββββββββ
Write-Host ""
Write-BoxTop
Write-BoxEmpty
Write-BoxLine " Setup Complete!" "Green"
Write-BoxEmpty
Write-BoxLine " Provider: $ProviderDisplayName" "White"
Write-BoxLine " Background: $BgMusicDisplayName" "White"
Write-BoxLine " Reverb: $ReverbDisplayName" "White"
Write-BoxLine " Verbosity: $VerbosityDisplayName" "White"
Write-BoxLine " Version: $Version" "DarkGray"
Write-BoxEmpty
Write-BoxBottom
Write-Host ""
Write-Host " Quick Start Commands:" -ForegroundColor Cyan
Write-Host ""
Write-Host " Test TTS" -ForegroundColor White
Write-Host " .\.claude\hooks-windows\play-tts.ps1 ""Hello from AgentVibes""" -ForegroundColor Gray
Write-Host ""
Write-Host " List voices" -ForegroundColor White
Write-Host " .\.claude\hooks-windows\voice-manager-windows.ps1 list" -ForegroundColor Gray
Write-Host ""
Write-Host " Switch provider" -ForegroundColor White
Write-Host " .\.claude\hooks-windows\provider-manager.ps1 set soprano" -ForegroundColor Gray
Write-Host ""
Write-Host " List providers" -ForegroundColor White
Write-Host " .\.claude\hooks-windows\provider-manager.ps1 list" -ForegroundColor Gray
Write-Host ""
Write-Host " Documentation:" -ForegroundColor Cyan
Write-Host " Setup Guide: WINDOWS-SETUP.md" -ForegroundColor Gray
Write-Host ""