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.
- package/LICENSE +21 -21
- package/README.md +462 -417
- package/README.zh-CN.md +433 -394
- package/adapters/dsh/install.ps1 +81 -81
- package/adapters/dsh/speech-hook.js +614 -561
- package/client/client.js +357 -340
- package/docs/DESIGN.md +60 -14
- package/docs/DESIGN.zh-CN.md +48 -12
- package/engine/speak.ps1 +214 -155
- package/engine/speak.sh +36 -6
- package/engine/speech-prompt.ps1 +24 -22
- package/engine/speech-summary.ps1 +27 -27
- package/package.json +82 -85
package/adapters/dsh/install.ps1
CHANGED
|
@@ -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)."
|