dsh-speak 1.8.0 → 1.8.2
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.
- package/LICENSE +21 -21
- package/README.md +529 -458
- package/README.zh-CN.md +485 -430
- package/adapters/dsh/install.ps1 +106 -81
- package/adapters/dsh/speech-hook.js +702 -614
- package/client/client.js +404 -357
- package/cordis.patch.yml +29 -5
- package/docs/DESIGN.md +106 -20
- package/docs/DESIGN.zh-CN.md +86 -19
- package/engine/speak.ps1 +214 -214
- package/engine/speak.sh +0 -0
- package/engine/speech-prompt.ps1 +24 -24
- package/engine/speech-summary.ps1 +27 -27
- package/package.json +77 -81
package/adapters/dsh/install.ps1
CHANGED
|
@@ -1,81 +1,106 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
# The entry id doubles as the settings namespace on DSH >= 0.1.7 (the settings
|
|
41
|
+
# service projects each entry's own Config), so the installer uses the id this
|
|
42
|
+
# package documents: dsh-speak. A profile still carrying the pre-1.8.2 row
|
|
43
|
+
# (id: speech-hook) is left alone — the browser half binds either id — so a
|
|
44
|
+
# re-run never registers the plugin twice.
|
|
45
|
+
#
|
|
46
|
+
# Two rows, deliberately: `insert` provides the entry, and the TOP-LEVEL row is the
|
|
47
|
+
# one the settings page persists into. DSH's config editor rewrites a `config` in
|
|
48
|
+
# place only on a top-level row; a `config` nested inside the insert is accepted by
|
|
49
|
+
# the UI, applied to the running plugin, and then silently rolled back on disk.
|
|
50
|
+
Write-Host "==> Registering plugin in cordis.patch.yml"
|
|
51
|
+
if (Test-Path $cordisPatch) {
|
|
52
|
+
$existing = Get-Content $cordisPatch -Raw -Encoding UTF8
|
|
53
|
+
$registered = $existing -match '(?m)^\s*- id:\s*dsh-speak\b'
|
|
54
|
+
$legacy = $existing -match '(?m)^\s*- id:\s*speech-hook\b'
|
|
55
|
+
if ($registered -or $legacy) {
|
|
56
|
+
if ($legacy -and -not $registered) {
|
|
57
|
+
Write-Host " an older 'id: speech-hook' row already registers dsh-speak — skipping."
|
|
58
|
+
Write-Host " (optional) rename that row's id to dsh-speak so your saved options live under the documented key."
|
|
59
|
+
} else {
|
|
60
|
+
Write-Host " dsh-speak already registered — skipping (nothing to do)."
|
|
61
|
+
}
|
|
62
|
+
Write-Host ""
|
|
63
|
+
Write-Host "Done. Restart the DSH web app to pick up the plugin."
|
|
64
|
+
exit 0
|
|
65
|
+
}
|
|
66
|
+
# backup before modifying
|
|
67
|
+
$backup = "$cordisPatch.bak-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
|
|
68
|
+
Copy-Item $cordisPatch $backup
|
|
69
|
+
Write-Host " backup -> $backup"
|
|
70
|
+
$block = @"
|
|
71
|
+
|
|
72
|
+
# dsh-speak: auto voice-announce assistant replies (installed by dsh-speak)
|
|
73
|
+
# insert = the entry itself; the top-level row is what the settings page edits.
|
|
74
|
+
- insert:
|
|
75
|
+
- id: dsh-speak
|
|
76
|
+
name: '$pluginUrl'
|
|
77
|
+
- id: dsh-speak
|
|
78
|
+
name: '$pluginUrl'
|
|
79
|
+
config: {}
|
|
80
|
+
"@
|
|
81
|
+
Add-Content -Path $cordisPatch -Value $block -Encoding UTF8
|
|
82
|
+
Write-Host " appended insert + settings entry -> $cordisPatch"
|
|
83
|
+
} else {
|
|
84
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $cordisPatch) | Out-Null
|
|
85
|
+
$content = @"
|
|
86
|
+
# dsh profile patch layer (created by dsh-speak installer)
|
|
87
|
+
# dsh-speak: auto voice-announce assistant replies
|
|
88
|
+
# insert = the entry itself; the top-level row is what the settings page edits.
|
|
89
|
+
- insert:
|
|
90
|
+
- id: dsh-speak
|
|
91
|
+
name: '$pluginUrl'
|
|
92
|
+
- id: dsh-speak
|
|
93
|
+
name: '$pluginUrl'
|
|
94
|
+
config: {}
|
|
95
|
+
"@
|
|
96
|
+
Set-Content -Path $cordisPatch -Value $content -Encoding UTF8
|
|
97
|
+
Write-Host " created -> $cordisPatch"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Write-Host ""
|
|
101
|
+
Write-Host "Installed. Next steps:"
|
|
102
|
+
Write-Host " 1. Restart the DSH web app (profile tree is composed at boot)."
|
|
103
|
+
Write-Host " 2. Verify voices: run"
|
|
104
|
+
Write-Host " powershell -NoProfile -ExecutionPolicy Bypass -File `"$EngineDir\speak.ps1`" -Text `"你好,语音播报已就绪。`""
|
|
105
|
+
Write-Host " 3. If no sound: install NaturalVoiceSAPIAdapter and register natural voices"
|
|
106
|
+
Write-Host " (see README.md -> Prerequisites)."
|