@voicethere/agent 0.9.7 → 0.10.0
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/README.md +78 -6
- package/dist/agent.js +27 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +40 -10
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime.d.ts +10 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +40 -35
- package/dist/runtime.js.map +1 -1
- package/dist/templates/echo/agent.js +27 -2
- package/dist/templates/echo-dc/agent.js +27 -2
- package/dist/templates/game-sync/agent.js +27 -2
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/language-switch/agent.js +132 -36
- package/dist/templates/positional-tts/agent.js +27 -2
- package/dist/templates/recording-consent/agent.js +27 -2
- package/dist/templates/registry.d.ts +7 -0
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +54 -0
- package/dist/templates/registry.js.map +1 -1
- package/dist/templates/spatial-showcase/agent.js +27 -2
- package/dist/templates/voice-showcase/agent.js +27 -2
- package/dist/templates/voice-starter/agent.js +27 -2
- package/dist/templates/webhooks/agent.js +27 -2
- package/dist/templates/webhooks-redis/agent.js +27 -2
- package/dist/templates/world-sync/agent.js +27 -2
- package/dist/templates/world-sync-binary/agent.js +27 -2
- package/dist/voice-provider-id.d.ts +14 -0
- package/dist/voice-provider-id.d.ts.map +1 -0
- package/dist/voice-provider-id.js +27 -0
- package/dist/voice-provider-id.js.map +1 -0
- package/dist/voice-request-validation.d.ts +19 -0
- package/dist/voice-request-validation.d.ts.map +1 -0
- package/dist/voice-request-validation.js +111 -0
- package/dist/voice-request-validation.js.map +1 -0
- package/package.json +1 -1
- package/templates/language-switch/README.md +4 -4
- package/templates/language-switch/agent.ts +12 -11
- package/templates/voice-starter/agent.ts +5 -2
|
@@ -16,7 +16,7 @@ When the switch took at least `readyMessageMinMs` (default 2000) and no wait mes
|
|
|
16
16
|
|
|
17
17
|
The swap waits until the holding message has finished playing (at most 8 seconds). If the language is detected after the caller's last final is already unanswered, that final is the switch utterance and the switch starts at once. If prepare or the swap fails for any other reason, the agent speaks a short fallback in the old language and stays. If only the replay fails, the voice is already the new one, so the agent asks the caller in the new language to repeat (`REPEAT_MESSAGES`) and stays in it. A second language event during a switch is ignored.
|
|
18
18
|
|
|
19
|
-
The built-in speech vendor is VoiceThere (id `
|
|
19
|
+
The built-in speech vendor is VoiceThere (id `voicethere`). Edit `PROFILES` in `agent.ts` to apply other vendors per target language, for example Deepgram for listening and ElevenLabs for speaking; the file has a commented example. Keys stay in project secrets.
|
|
20
20
|
|
|
21
21
|
Texts, in order of precedence: the env override, the project settings (`waitMessages`, `readyMessages`), then the maps in `agent.ts` (`HOLDING_MESSAGES`, `READY_MESSAGES`, `FAILED_MESSAGES`, `UNAVAILABLE_MESSAGES`; en, de, es, fr, it, pt, nl, pl, ru, except the ready and unavailable maps, which have no ru). `WAIT_MESSAGES` is kept as another name for `HOLDING_MESSAGES`. In a holding message, `{language}` is replaced by the target language's name, written in the language being left (`Intl.DisplayNames`), so project texts and the env override can use it too. Override per language with a JSON object in the session env, keyed by ISO 639-1 code:
|
|
22
22
|
|
|
@@ -40,13 +40,13 @@ Detection and chat commands are unchanged: `/tts` and `/stt` still call `setVoic
|
|
|
40
40
|
|
|
41
41
|
Chat commands change one vendor while the session stays connected. API keys are project secrets on the running deploy, not arguments:
|
|
42
42
|
|
|
43
|
-
- `/tts
|
|
44
|
-
- `/stt
|
|
43
|
+
- `/tts voicethere de` — VoiceThere TTS only (`sherpa` also works)
|
|
44
|
+
- `/stt voicethere de` — VoiceThere STT only (`sherpa` also works)
|
|
45
45
|
- `/tts elevenlabs` — ElevenLabs TTS, current STT stays
|
|
46
46
|
- `/stt deepgram de` — Deepgram STT, current voice stays
|
|
47
47
|
|
|
48
48
|
In manual mode, finals are echoed as `you said: …` (in the current language) after a short wait, so a language event for the same utterance can cancel the echo. The switch utterance is not spoken back as an English transcript; its replay is answered in the new language.
|
|
49
49
|
|
|
50
|
-
`
|
|
50
|
+
The default profile asks for VoiceThere speech on both sides: `sttVendor: { provider: "voicethere", language }` and `ttsVendor: { provider: "voicethere", language }`. To pick a specific model or voice, set `sttVendor.model` (`de`, `en-small`) or `ttsVendor.voice` (`en-lessac`); the ids are listed in the spoken-language docs. Other vendor ids are `openai`, `deepgram`, `assemblyai`, `google`, `elevenlabs`, `cartesia`, `fishaudio`, `groq`, `azure`, and `aws`. A failed switch carries a `reason` and a `message` that says what to change.
|
|
51
51
|
|
|
52
52
|
Entry: `templates/language-switch/agent.ts`.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* FAILED_MESSAGES / UNAVAILABLE_MESSAGES, and env vars
|
|
28
28
|
* LANGUAGE_SWITCH_WAIT_MESSAGES_JSON / LANGUAGE_SWITCH_FAILED_MESSAGES_JSON /
|
|
29
29
|
* LANGUAGE_SWITCH_UNAVAILABLE_MESSAGES_JSON (JSON object, ISO 639-1 ->
|
|
30
|
-
* text) win. The built-in vendor is VoiceThere (id `
|
|
30
|
+
* text) win. The built-in vendor is VoiceThere (id `voicethere`); edit
|
|
31
31
|
* PROFILES to use other vendors.
|
|
32
32
|
* (B) Project enables runner auto-switch — STT/TTS are runner-owned. The
|
|
33
33
|
* runner replays the utterance into the new language's STT, so the next
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
*
|
|
41
41
|
* Chat commands change a single vendor mid-conversation:
|
|
42
42
|
*
|
|
43
|
-
* - `/tts
|
|
44
|
-
* - `/stt
|
|
43
|
+
* - `/tts voicethere de` — VoiceThere TTS only (`sherpa` also works)
|
|
44
|
+
* - `/stt voicethere de` — VoiceThere STT only (`sherpa` also works)
|
|
45
45
|
* - `/tts elevenlabs` — ElevenLabs TTS, current STT stays
|
|
46
46
|
* - `/stt deepgram de` — Deepgram STT, current voice stays
|
|
47
47
|
*
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* What to apply per target language. The default is the built-in VoiceThere
|
|
68
|
-
* vendor (`
|
|
68
|
+
* vendor (`voicethere`): voice and STT model chosen for the language. A
|
|
69
69
|
* profile can name other vendors; keys stay in project secrets. Example:
|
|
70
70
|
*
|
|
71
71
|
* de: {
|
|
@@ -82,8 +82,8 @@ export function profileFor(language: string): SetVoiceLanguageOptions {
|
|
|
82
82
|
PROFILES[language] ?? {
|
|
83
83
|
scope: "both",
|
|
84
84
|
language,
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
sttVendor: { provider: "voicethere", language },
|
|
86
|
+
ttsVendor: { provider: "voicethere", language },
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
89
|
}
|
|
@@ -324,7 +324,7 @@ function logSwitch(
|
|
|
324
324
|
if (!result.ok) {
|
|
325
325
|
agentLog(
|
|
326
326
|
"warn",
|
|
327
|
-
`setVoiceLanguage ${side} failed: ${result.reason ?? "unknown"}`,
|
|
327
|
+
`setVoiceLanguage ${side} failed: ${result.reason ?? "unknown"}${result.message ? ` - ${result.message}` : ""}`,
|
|
328
328
|
);
|
|
329
329
|
return;
|
|
330
330
|
}
|
|
@@ -832,21 +832,22 @@ defineAgent({
|
|
|
832
832
|
const text = parseChatText(ctx.message);
|
|
833
833
|
if (!text) return;
|
|
834
834
|
const [command, vendor, language] = text.trim().split(/\s+/);
|
|
835
|
-
|
|
835
|
+
const builtIn = vendor === "voicethere" || vendor === "sherpa";
|
|
836
|
+
if (command === "/tts" && builtIn && language) {
|
|
836
837
|
const result = await setVoiceLanguage(ctx.sessionId, {
|
|
837
838
|
scope: "tts",
|
|
838
839
|
language,
|
|
839
|
-
ttsVendor: { provider: "
|
|
840
|
+
ttsVendor: { provider: "voicethere", language },
|
|
840
841
|
});
|
|
841
842
|
logSwitch(ctx.sessionId, "tts", result);
|
|
842
843
|
if (result.ok) speak(ctx.sessionId, replyFor(language));
|
|
843
844
|
return;
|
|
844
845
|
}
|
|
845
|
-
if (command === "/stt" &&
|
|
846
|
+
if (command === "/stt" && builtIn && language) {
|
|
846
847
|
const result = await setVoiceLanguage(ctx.sessionId, {
|
|
847
848
|
scope: "stt",
|
|
848
849
|
language,
|
|
849
|
-
sttVendor: { provider: "
|
|
850
|
+
sttVendor: { provider: "voicethere", language },
|
|
850
851
|
});
|
|
851
852
|
logSwitch(ctx.sessionId, "stt", result);
|
|
852
853
|
return;
|
|
@@ -179,8 +179,11 @@ defineAgent({
|
|
|
179
179
|
},
|
|
180
180
|
|
|
181
181
|
onUserLanguage({ sessionId, language }) {
|
|
182
|
-
// Detection does not change TTS or STT. Call setVoiceLanguage
|
|
183
|
-
// scope "
|
|
182
|
+
// Detection does not change TTS or STT. Call setVoiceLanguage, for example
|
|
183
|
+
// { scope: "both", language,
|
|
184
|
+
// sttVendor: { provider: "voicethere", language },
|
|
185
|
+
// ttsVendor: { provider: "voicethere", language } }
|
|
186
|
+
// or name another provider (deepgram, elevenlabs, ...) per side.
|
|
184
187
|
// See templates/language-switch/agent.ts.
|
|
185
188
|
agentLog("info", `user_language ${sessionId} ${language}`);
|
|
186
189
|
},
|