dsh-speak 1.7.4 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +1,81 @@
1
- # install.ps1 — one-command installer for the DSH adapter
2
- # ========================================================
3
- # 1. copies engine/*.ps1 to ~/.dsh/hooks/
4
- # 2. copies speech-hook.js to ~/.dsh/profiles/web/plugins/
5
- # 3. registers the plugin in ~/.dsh/profiles/web/cordis.patch.yml (backs it up first)
6
- #
7
- # Usage:
8
- # powershell.exe -NoProfile -ExecutionPolicy Bypass -File install.ps1
9
- # powershell.exe -NoProfile -ExecutionPolicy Bypass -File install.ps1 -DshHome C:\Users\you\.dsh -PluginsDir C:\Users\you\.dsh\profiles\web\plugins
10
- #
11
- # After installing, restart the DSH web app (the profile tree is composed at boot).
12
-
13
- param(
14
- [string]$DshHome = (Join-Path $env:USERPROFILE '.dsh'),
15
- [string]$EngineDir = '',
16
- [string]$PluginsDir = ''
17
- )
18
-
19
- $ErrorActionPreference = 'Stop'
20
- $here = Split-Path -Parent $MyInvocation.MyCommand.Path
21
- $repoRoot = Resolve-Path (Join-Path $here '..\..')
22
-
23
- if (-not $EngineDir) { $EngineDir = Join-Path $DshHome 'hooks' }
24
- if (-not $PluginsDir) { $PluginsDir = Join-Path $DshHome 'profiles\web\plugins' }
25
- $cordisPatch = Join-Path $DshHome 'profiles\web\cordis.patch.yml'
26
-
27
- # ---------- 1. engine ----------
28
- Write-Host "==> Installing engine -> $EngineDir"
29
- New-Item -ItemType Directory -Force -Path $EngineDir | Out-Null
30
- Copy-Item -Force (Join-Path $repoRoot 'engine\*.ps1') $EngineDir
31
- Write-Host " copied: $((Get-ChildItem (Join-Path $repoRoot 'engine\*.ps1')).Count) script(s)"
32
-
33
- # ---------- 2. plugin ----------
34
- Write-Host "==> Installing DSH plugin -> $PluginsDir"
35
- New-Item -ItemType Directory -Force -Path $PluginsDir | Out-Null
36
- Copy-Item -Force (Join-Path $here 'speech-hook.js') $PluginsDir
37
- $pluginUrl = 'file:///' + ((Join-Path $PluginsDir 'speech-hook.js') -replace '\\', '/' -replace ' ', '%20')
38
-
39
- # ---------- 3. register in cordis.patch.yml ----------
40
- Write-Host "==> Registering plugin in cordis.patch.yml"
41
- if (Test-Path $cordisPatch) {
42
- $existing = Get-Content $cordisPatch -Raw -Encoding UTF8
43
- if ($existing -match '(?m)^\s*- id:\s*speech-hook\b') {
44
- Write-Host " speech-hook already registered — skipping (nothing to do)."
45
- Write-Host ""
46
- Write-Host "Done. Restart the DSH web app to pick up the plugin."
47
- exit 0
48
- }
49
- # backup before modifying
50
- $backup = "$cordisPatch.bak-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
51
- Copy-Item $cordisPatch $backup
52
- Write-Host " backup -> $backup"
53
- $block = @"
54
-
55
- # speech-hook: auto voice-announce assistant replies (installed by dsh-speak)
56
- - insert:
57
- - id: speech-hook
58
- name: '$pluginUrl'
59
- "@
60
- Add-Content -Path $cordisPatch -Value $block -Encoding UTF8
61
- Write-Host " appended insert entry -> $cordisPatch"
62
- } else {
63
- New-Item -ItemType Directory -Force -Path (Split-Path $cordisPatch) | Out-Null
64
- $content = @"
65
- # dsh profile patch layer (created by dsh-speak installer)
66
- # speech-hook: auto voice-announce assistant replies
67
- - insert:
68
- - id: speech-hook
69
- name: '$pluginUrl'
70
- "@
71
- Set-Content -Path $cordisPatch -Value $content -Encoding UTF8
72
- Write-Host " created -> $cordisPatch"
73
- }
74
-
75
- Write-Host ""
76
- Write-Host "Installed. Next steps:"
77
- Write-Host " 1. Restart the DSH web app (profile tree is composed at boot)."
78
- Write-Host " 2. Verify voices: run"
79
- Write-Host " powershell -NoProfile -ExecutionPolicy Bypass -File `"$EngineDir\speak.ps1`" -Text `"你好,语音播报已就绪。`""
80
- Write-Host " 3. If no sound: install NaturalVoiceSAPIAdapter and register natural voices"
81
- Write-Host " (see README.md -> Prerequisites)."
1
+ # install.ps1 — one-command installer for the DSH adapter
2
+ # ========================================================
3
+ # 1. copies engine/*.ps1 to ~/.dsh/hooks/
4
+ # 2. copies speech-hook.js to ~/.dsh/profiles/web/plugins/
5
+ # 3. registers the plugin in ~/.dsh/profiles/web/cordis.patch.yml (backs it up first)
6
+ #
7
+ # Usage:
8
+ # powershell.exe -NoProfile -ExecutionPolicy Bypass -File install.ps1
9
+ # powershell.exe -NoProfile -ExecutionPolicy Bypass -File install.ps1 -DshHome C:\Users\you\.dsh -PluginsDir C:\Users\you\.dsh\profiles\web\plugins
10
+ #
11
+ # After installing, restart the DSH web app (the profile tree is composed at boot).
12
+
13
+ param(
14
+ [string]$DshHome = (Join-Path $env:USERPROFILE '.dsh'),
15
+ [string]$EngineDir = '',
16
+ [string]$PluginsDir = ''
17
+ )
18
+
19
+ $ErrorActionPreference = 'Stop'
20
+ $here = Split-Path -Parent $MyInvocation.MyCommand.Path
21
+ $repoRoot = Resolve-Path (Join-Path $here '..\..')
22
+
23
+ if (-not $EngineDir) { $EngineDir = Join-Path $DshHome 'hooks' }
24
+ if (-not $PluginsDir) { $PluginsDir = Join-Path $DshHome 'profiles\web\plugins' }
25
+ $cordisPatch = Join-Path $DshHome 'profiles\web\cordis.patch.yml'
26
+
27
+ # ---------- 1. engine ----------
28
+ Write-Host "==> Installing engine -> $EngineDir"
29
+ New-Item -ItemType Directory -Force -Path $EngineDir | Out-Null
30
+ Copy-Item -Force (Join-Path $repoRoot 'engine\*.ps1') $EngineDir
31
+ Write-Host " copied: $((Get-ChildItem (Join-Path $repoRoot 'engine\*.ps1')).Count) script(s)"
32
+
33
+ # ---------- 2. plugin ----------
34
+ Write-Host "==> Installing DSH plugin -> $PluginsDir"
35
+ New-Item -ItemType Directory -Force -Path $PluginsDir | Out-Null
36
+ Copy-Item -Force (Join-Path $here 'speech-hook.js') $PluginsDir
37
+ $pluginUrl = 'file:///' + ((Join-Path $PluginsDir 'speech-hook.js') -replace '\\', '/' -replace ' ', '%20')
38
+
39
+ # ---------- 3. register in cordis.patch.yml ----------
40
+ Write-Host "==> Registering plugin in cordis.patch.yml"
41
+ if (Test-Path $cordisPatch) {
42
+ $existing = Get-Content $cordisPatch -Raw -Encoding UTF8
43
+ if ($existing -match '(?m)^\s*- id:\s*speech-hook\b') {
44
+ Write-Host " speech-hook already registered — skipping (nothing to do)."
45
+ Write-Host ""
46
+ Write-Host "Done. Restart the DSH web app to pick up the plugin."
47
+ exit 0
48
+ }
49
+ # backup before modifying
50
+ $backup = "$cordisPatch.bak-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
51
+ Copy-Item $cordisPatch $backup
52
+ Write-Host " backup -> $backup"
53
+ $block = @"
54
+
55
+ # speech-hook: auto voice-announce assistant replies (installed by dsh-speak)
56
+ - insert:
57
+ - id: speech-hook
58
+ name: '$pluginUrl'
59
+ "@
60
+ Add-Content -Path $cordisPatch -Value $block -Encoding UTF8
61
+ Write-Host " appended insert entry -> $cordisPatch"
62
+ } else {
63
+ New-Item -ItemType Directory -Force -Path (Split-Path $cordisPatch) | Out-Null
64
+ $content = @"
65
+ # dsh profile patch layer (created by dsh-speak installer)
66
+ # speech-hook: auto voice-announce assistant replies
67
+ - insert:
68
+ - id: speech-hook
69
+ name: '$pluginUrl'
70
+ "@
71
+ Set-Content -Path $cordisPatch -Value $content -Encoding UTF8
72
+ Write-Host " created -> $cordisPatch"
73
+ }
74
+
75
+ Write-Host ""
76
+ Write-Host "Installed. Next steps:"
77
+ Write-Host " 1. Restart the DSH web app (profile tree is composed at boot)."
78
+ Write-Host " 2. Verify voices: run"
79
+ Write-Host " powershell -NoProfile -ExecutionPolicy Bypass -File `"$EngineDir\speak.ps1`" -Text `"你好,语音播报已就绪。`""
80
+ Write-Host " 3. If no sound: install NaturalVoiceSAPIAdapter and register natural voices"
81
+ Write-Host " (see README.md -> Prerequisites)."