Skip to content

Commit 3c08e1d

Browse files
committed
Complete Text to Speech profile and emotion gaps
1 parent 237eee8 commit 3c08e1d

13 files changed

Lines changed: 3175 additions & 476 deletions

File tree

assets/toolbox/text-to-speech/js/index.js

Lines changed: 204 additions & 64 deletions
Large diffs are not rendered by default.

docs_build/database/ddl/messages.sql

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Target DEV database: gamefoundry_dev
55
-- Scope: executable grouped table DDL for active server API migration.
66
-- Authoritative key values are generated by the server/API layer unless a later DEV-only seed exception explicitly applies.
7-
-- Owned tables: messages_categories, messages_emotion_profiles, messages_tts_profiles, messages_records, messages_segments
7+
-- Owned tables: messages_categories, messages_emotion_profiles, messages_tts_profiles, messages_tts_profile_emotion_settings, messages_records, messages_segments, messages_event_actions
88
CREATE TABLE IF NOT EXISTS messages_categories (
99
key text PRIMARY KEY,
1010
"name" text NOT NULL UNIQUE,
@@ -31,30 +31,48 @@ CREATE TABLE IF NOT EXISTS messages_emotion_profiles (
3131
"updatedBy" text NOT NULL REFERENCES users(key)
3232
);
3333

34-
CREATE TABLE IF NOT EXISTS messages_records (
34+
CREATE TABLE IF NOT EXISTS messages_tts_profiles (
3535
key text PRIMARY KEY,
36-
"name" text NOT NULL,
37-
"categoryKey" text NOT NULL REFERENCES messages_categories(key),
38-
"emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
39-
"messageText" text NOT NULL,
40-
"notes" text NOT NULL DEFAULT '',
36+
"name" text NOT NULL UNIQUE,
37+
"description" text NOT NULL DEFAULT '',
38+
"providerKey" text NOT NULL,
39+
"voiceName" text NOT NULL DEFAULT '',
40+
"language" text NOT NULL,
41+
"volume" numeric NOT NULL DEFAULT 1,
42+
"pitch" numeric NOT NULL DEFAULT 1,
43+
"rate" numeric NOT NULL DEFAULT 1,
4144
"active" boolean NOT NULL DEFAULT true,
4245
"createdAt" timestamptz NOT NULL DEFAULT now(),
4346
"updatedAt" timestamptz NOT NULL DEFAULT now(),
4447
"createdBy" text NOT NULL REFERENCES users(key),
4548
"updatedBy" text NOT NULL REFERENCES users(key)
4649
);
4750

48-
CREATE TABLE IF NOT EXISTS messages_tts_profiles (
51+
CREATE TABLE IF NOT EXISTS messages_tts_profile_emotion_settings (
4952
key text PRIMARY KEY,
50-
"name" text NOT NULL UNIQUE,
51-
"description" text NOT NULL DEFAULT '',
52-
"providerKey" text NOT NULL,
53-
"voiceName" text NOT NULL DEFAULT '',
54-
"language" text NOT NULL,
53+
"ttsProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
54+
"emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
5555
"volume" numeric NOT NULL DEFAULT 1,
5656
"pitch" numeric NOT NULL DEFAULT 1,
5757
"rate" numeric NOT NULL DEFAULT 1,
58+
"displayOrder" integer NOT NULL DEFAULT 0,
59+
"ssmlLikePreset" text NOT NULL DEFAULT 'normal',
60+
"active" boolean NOT NULL DEFAULT true,
61+
"createdAt" timestamptz NOT NULL DEFAULT now(),
62+
"updatedAt" timestamptz NOT NULL DEFAULT now(),
63+
"createdBy" text NOT NULL REFERENCES users(key),
64+
"updatedBy" text NOT NULL REFERENCES users(key),
65+
UNIQUE ("ttsProfileKey", "emotionProfileKey")
66+
);
67+
68+
CREATE TABLE IF NOT EXISTS messages_records (
69+
key text PRIMARY KEY,
70+
"name" text NOT NULL,
71+
"categoryKey" text NOT NULL REFERENCES messages_categories(key),
72+
"emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
73+
"voiceProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
74+
"messageText" text NOT NULL,
75+
"notes" text NOT NULL DEFAULT '',
5876
"active" boolean NOT NULL DEFAULT true,
5977
"createdAt" timestamptz NOT NULL DEFAULT now(),
6078
"updatedAt" timestamptz NOT NULL DEFAULT now(),
@@ -66,6 +84,7 @@ CREATE TABLE IF NOT EXISTS messages_segments (
6684
key text PRIMARY KEY,
6785
"messageKey" text NOT NULL REFERENCES messages_records(key),
6886
"emotionProfileKey" text NOT NULL REFERENCES messages_emotion_profiles(key),
87+
"voiceProfileKey" text NOT NULL REFERENCES messages_tts_profiles(key),
6988
"segmentText" text NOT NULL,
7089
"displayOrder" integer NOT NULL,
7190
"active" boolean NOT NULL DEFAULT true,
@@ -75,15 +94,38 @@ CREATE TABLE IF NOT EXISTS messages_segments (
7594
"updatedBy" text NOT NULL REFERENCES users(key)
7695
);
7796

97+
CREATE TABLE IF NOT EXISTS messages_event_actions (
98+
key text PRIMARY KEY,
99+
"name" text NOT NULL,
100+
"actionType" text NOT NULL,
101+
"messageKey" text REFERENCES messages_records(key),
102+
"active" boolean NOT NULL DEFAULT true,
103+
"createdAt" timestamptz NOT NULL DEFAULT now(),
104+
"updatedAt" timestamptz NOT NULL DEFAULT now(),
105+
"createdBy" text NOT NULL REFERENCES users(key),
106+
"updatedBy" text NOT NULL REFERENCES users(key)
107+
);
108+
78109
CREATE INDEX IF NOT EXISTS idx_messages_records_categorykey ON messages_records ("categoryKey");
79110
CREATE INDEX IF NOT EXISTS idx_messages_records_emotionprofilekey ON messages_records ("emotionProfileKey");
111+
CREATE INDEX IF NOT EXISTS idx_messages_records_voiceprofilekey ON messages_records ("voiceProfileKey");
80112
CREATE INDEX IF NOT EXISTS idx_messages_records_createdby ON messages_records ("createdBy");
81113
CREATE INDEX IF NOT EXISTS idx_messages_records_updatedby ON messages_records ("updatedBy");
82114
CREATE INDEX IF NOT EXISTS idx_messages_segments_messagekey ON messages_segments ("messageKey");
83115
CREATE INDEX IF NOT EXISTS idx_messages_segments_emotionprofilekey ON messages_segments ("emotionProfileKey");
116+
CREATE INDEX IF NOT EXISTS idx_messages_segments_voiceprofilekey ON messages_segments ("voiceProfileKey");
84117
CREATE INDEX IF NOT EXISTS idx_messages_segments_order ON messages_segments ("messageKey", "displayOrder");
85118
CREATE INDEX IF NOT EXISTS idx_messages_segments_createdby ON messages_segments ("createdBy");
86119
CREATE INDEX IF NOT EXISTS idx_messages_segments_updatedby ON messages_segments ("updatedBy");
120+
CREATE INDEX IF NOT EXISTS idx_messages_event_actions_actiontype ON messages_event_actions ("actionType");
121+
CREATE INDEX IF NOT EXISTS idx_messages_event_actions_messagekey ON messages_event_actions ("messageKey");
122+
CREATE INDEX IF NOT EXISTS idx_messages_event_actions_createdby ON messages_event_actions ("createdBy");
123+
CREATE INDEX IF NOT EXISTS idx_messages_event_actions_updatedby ON messages_event_actions ("updatedBy");
87124
CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_providerkey ON messages_tts_profiles ("providerKey");
88125
CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_createdby ON messages_tts_profiles ("createdBy");
89126
CREATE INDEX IF NOT EXISTS idx_messages_tts_profiles_updatedby ON messages_tts_profiles ("updatedBy");
127+
CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_ttsprofilekey ON messages_tts_profile_emotion_settings ("ttsProfileKey");
128+
CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_emotionprofilekey ON messages_tts_profile_emotion_settings ("emotionProfileKey");
129+
CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_order ON messages_tts_profile_emotion_settings ("ttsProfileKey", "displayOrder");
130+
CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_createdby ON messages_tts_profile_emotion_settings ("createdBy");
131+
CREATE INDEX IF NOT EXISTS idx_messages_tts_profile_emotion_settings_updatedby ON messages_tts_profile_emotion_settings ("updatedBy");
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# PR_26177_BRAVO_002 Complete Text To Speech Gap Fixes
2+
3+
## Branch Validation
4+
5+
| Check | Result | Notes |
6+
| --- | --- | --- |
7+
| Active branch | PASS | `bravo/26177-text-to-speech` |
8+
| Did not switch to main | PASS | Work stayed on the active Bravo branch. |
9+
| Scope | PASS | Text To Speech profiles, Emotion Profile settings, Messages integration, preview/usage/delete protection, tests, reports. |
10+
| No `start_of_day` changes | PASS | `git status --short -- docs_build/dev/start_of_day start_of_day` returned no changed files. |
11+
12+
## Audit Checklist
13+
14+
| Area | Result | Notes |
15+
| --- | --- | --- |
16+
| TTS Profiles | PASS | Text To Speech now loads/saves/deletes TTS Profiles through Local API/database contracts, not browser-owned product storage. |
17+
| Emotion Profiles | PASS | Added server-owned TTS Profile to Emotion Profile settings with pitch/rate/volume/preset, order, usage, and reference protection. |
18+
| Messages integration | PASS | Messages consumes `listTtsProfiles()` directly and no longer syncs browser-saved profiles into the API. |
19+
| Preview playback | PASS | Existing Web Speech preview remains in Text To Speech and Messages playback uses selected TTS Profile emotion settings. |
20+
| Used-by / usage visibility | PASS | TTS Profiles and profile emotion settings expose message/sentence usage counts and references; Text To Speech shows Usage columns. |
21+
| Delete protection | PASS | Referenced TTS Profiles, profile emotion settings, and Emotion Profiles are blocked server-side before destructive changes. |
22+
| Targeted tests | PASS | Focused Node lane is green: 14/14 tests. |
23+
24+
## File Inventory
25+
26+
| File | Purpose |
27+
| --- | --- |
28+
| `src/dev-runtime/messages/messages-postgres-service.mjs` | Added profile emotion settings table/seed/API contract, usage counts, publish validation, delete/deactivate protection. |
29+
| `toolbox/messages/messages-api-client.js` | Added TTS Profile and Emotion Profile delete actions. |
30+
| `toolbox/messages/messages.js` | Removed browser profile-store sync; Messages now uses Local API TTS Profiles directly. |
31+
| `assets/toolbox/text-to-speech/js/index.js` | Moved live TTS Profile workflow to Local API and surfaced usage counts. |
32+
| `toolbox/text-to-speech/index.html` | Added TTS Profile Usage column. |
33+
| `docs_build/database/ddl/messages.sql` | Aligned static Messages DDL with runtime TTS/Profile/Emotion/Event Action schema. |
34+
| `tests/dev-runtime/MessagesPublishValidation.test.mjs` | Added API/service coverage for usage counts, profile-scoped emotion settings, and reference protection. |
35+
| `tests/tools/MessagesPlaybackSource.test.mjs` | Updated source guards to require API-owned TTS Profile loading. |
36+
| `tests/tools/Text2SpeechShell.test.mjs` | Removed saved-profile-store expectations and added Local API source guard. |
37+
| `tests/playwright/tools/MessagesTool.spec.mjs` | Removed stale profile-store import/localStorage fixture; renamed coverage to Local API TTS Profiles. |
38+
39+
## DB/API Inventory
40+
41+
- Added runtime table: `messages_tts_profile_emotion_settings`.
42+
- Added static DDL for `messages_tts_profile_emotion_settings`, `messages_records."voiceProfileKey"`, `messages_segments."voiceProfileKey"`, voice indexes, and `messages_event_actions`.
43+
- Seeded explicit profile emotion settings:
44+
- Default Balanced Profile: Neutral, Calm, Urgent.
45+
- Man Profile 1: Neutral, Calm, Urgent.
46+
- Woman Profile 2: Whisper, Robot.
47+
- Added TTS Profile usage/reference projection: `messageUsageCount`, `segmentUsageCount`, `usageCount`, `references`.
48+
- Added profile emotion setting usage/reference projection.
49+
- Added Local API delete actions:
50+
- `POST /api/messages/tts-profiles/:key/delete`
51+
- `POST /api/messages/emotion-profiles/:key/delete`
52+
- Extended publish validation for inactive profiles and missing selected TTS Profile emotion settings.
53+
54+
## Test Inventory
55+
56+
| Command | Result |
57+
| --- | --- |
58+
| `node --check src/dev-runtime/messages/messages-postgres-service.mjs; node --check assets/toolbox/text-to-speech/js/index.js; node --check toolbox/messages/messages.js; node --check toolbox/messages/messages-api-client.js` | PASS |
59+
| `node --test tests/tools/Text2SpeechShell.test.mjs tests/tools/MessagesPlaybackSource.test.mjs tests/dev-runtime/MessagesPublishValidation.test.mjs` | PASS, 14/14 |
60+
| `npx playwright test tests/playwright/tools/MessagesTool.spec.mjs --project=playwright` | BLOCKED/FAIL, Chromium executable missing at `C:\Users\davidq\AppData\Local\ms-playwright\chromium-1217\chrome-win64\chrome.exe`. |
61+
| `node --test ... tests/dev-runtime/DbSeedIntegrity.test.mjs` included during exploratory validation | PARTIAL, Messages seed test passed; two unrelated Local DB snapshot tests failed before this PR's assertions. |
62+
63+
## Playwright Impacted Assessment
64+
65+
Impacted specs:
66+
67+
- `tests/playwright/tools/MessagesTool.spec.mjs`
68+
- `tests/playwright/tools/TextToSpeechFunctional.spec.mjs`
69+
- `tests/playwright/tools/EventsTool.spec.mjs` indirectly uses Messages TTS/Emotion API rows.
70+
71+
Assessment:
72+
73+
- The stale `MessagesTool.spec.mjs` TTS profile-store import is fixed.
74+
- Browser validation is still blocked locally by missing Chromium.
75+
- Once Chromium is installed, rerun Messages, Text To Speech, and Events together because the workflow crosses Local API profile settings, message creation, sentence emotion filtering, and playback.
76+
77+
## Exact Remaining Implementation PR Recommendations
78+
79+
1. `PR_26177_BRAVO_003-playwright-browser-validation-closeout`
80+
- Install the configured Playwright Chromium browser or run in an environment with the browser available.
81+
- Rerun `MessagesTool.spec.mjs`, `TextToSpeechFunctional.spec.mjs`, and `EventsTool.spec.mjs`.
82+
- Apply only browser-lane fixes discovered by those specs.
83+
84+
2. `PR_26177_BRAVO_004-global-emotion-profile-authoring-if-needed`
85+
- Only if product wants creators to author the global Emotion Profile catalog outside TTS Profile settings.
86+
- Keep it API/database-owned and avoid browser-owned product data.
87+
88+
No additional Team Bravo TTS implementation gap is currently recommended from the focused API/service/UI/test pass.
89+
90+
## Manual Validation Notes
91+
92+
- Manual browser validation was not completed because Playwright Chromium is not installed locally.
93+
- Source inspection confirmed Text To Speech and Messages no longer import the TTS profile browser store.
94+
- Source inspection confirmed changed runtime/test files contain no `imageDataUrl` references.
95+
- Source inspection confirmed no `start_of_day` files were modified.
96+
97+
## Known Issues
98+
99+
- Playwright browser execution is blocked by missing Chromium on this machine.
100+
- External paid/provider TTS adapters remain planned and are outside this PR's browser preview/API profile scope.
101+
- Dedicated global Emotion Profile authoring UI remains optional pending product decision; profile-scoped emotion settings are implemented.
102+
103+
## Output Files
104+
105+
- `docs_build/dev/reports/codex_review.diff`
106+
- `docs_build/dev/reports/codex_changed_files.txt`
107+
- `docs_build/dev/reports/PR_26177_BRAVO_002-complete-text-to-speech-gap-fixes.md`
108+
- `tmp/PR_26177_BRAVO_002-complete-text-to-speech-gap-fixes_delta.zip`
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# Scoped changed files
2-
M docs_build/dev/ProjectInstructions/team_assignments/TEAM_ASSIGNMENTS.md
3-
M docs_build/dev/reports/codex_changed_files.txt
4-
M docs_build/dev/reports/codex_review.diff
5-
A docs_build/dev/reports/PR_26177_BRAVO_002-correct-team-branch-governance.md
6-
7-
# Branch correction preserved from prior commit on Bravo branch
8-
A docs_build/dev/reports/PR_26177_BRAVO_001-audit-text-to-speech-profiles-emotions.md
9-
10-
# Notes
11-
- No implementation files were modified.
12-
- Local `main` was restored to `origin/main`.
13-
- Current work remains on `bravo/26177-text-to-speech`.
14-
- Required delta ZIP is generated under `tmp/` and must not be staged.
1+
assets/toolbox/text-to-speech/js/index.js
2+
docs_build/database/ddl/messages.sql
3+
docs_build/dev/reports/PR_26177_BRAVO_002-complete-text-to-speech-gap-fixes.md
4+
docs_build/dev/reports/codex_changed_files.txt
5+
docs_build/dev/reports/codex_review.diff
6+
src/dev-runtime/messages/messages-postgres-service.mjs
7+
tests/dev-runtime/MessagesPublishValidation.test.mjs
8+
tests/playwright/tools/MessagesTool.spec.mjs
9+
tests/tools/MessagesPlaybackSource.test.mjs
10+
tests/tools/Text2SpeechShell.test.mjs
11+
toolbox/messages/messages-api-client.js
12+
toolbox/messages/messages.js
13+
toolbox/text-to-speech/index.html

0 commit comments

Comments
 (0)