@jskit-ai/assistant-voice 0.1.45 → 0.2.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.
@@ -9,14 +9,14 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@fastify/websocket": "^11.2.0",
12
- "@jskit-ai/assistant-core": "0.1.244",
13
- "@jskit-ai/assistant-runtime": "0.1.238",
14
- "@jskit-ai/assistant-voice": "0.1.45",
15
- "@jskit-ai/connectors-catalog": "0.1.67",
16
- "@jskit-ai/http-runtime": "0.1.246",
17
- "@jskit-ai/kernel": "0.1.248",
18
- "@jskit-ai/realtime": "0.1.248",
19
- "@jskit-ai/shell-web": "0.1.255",
12
+ "@jskit-ai/assistant-core": "0.2.0",
13
+ "@jskit-ai/assistant-runtime": "0.2.0",
14
+ "@jskit-ai/assistant-voice": "0.2.0",
15
+ "@jskit-ai/connectors-catalog": "0.2.0",
16
+ "@jskit-ai/http-runtime": "0.2.0",
17
+ "@jskit-ai/kernel": "0.2.0",
18
+ "@jskit-ai/realtime": "0.2.0",
19
+ "@jskit-ai/shell-web": "0.2.0",
20
20
  "@mdi/js": "^7.4.47",
21
21
  "@tanstack/vue-query": "^5.90.5",
22
22
  "fastify": "^5.8.0",
@@ -0,0 +1,182 @@
1
+ {
2
+ "jskit": {
3
+ "assistant": {
4
+ "voice": {
5
+ "assistant": "Assistant",
6
+ "dialog": {
7
+ "label": "{title} conversation",
8
+ "minimize": "Minimize conversation",
9
+ "close": "Close conversation",
10
+ "modes": "Conversation mode",
11
+ "talk": "Talk",
12
+ "text": "Text"
13
+ },
14
+ "host": {
15
+ "close": "Close voice chat",
16
+ "switchPrompt": "Finish or discard your recording for {current} before switching to {next}.",
17
+ "thisConversation": "this conversation",
18
+ "anotherConversation": "another conversation",
19
+ "stayHere": "Stay here",
20
+ "discardAndSwitch": "Discard and switch",
21
+ "switch": "Switch",
22
+ "stopWork": "Stop agent work",
23
+ "reopen": "{label} · Voice chat"
24
+ },
25
+ "conversation": {
26
+ "listening": "Listening",
27
+ "speaking": "Speaking",
28
+ "captions": "Voice conversation text",
29
+ "recognizedWords": "Recognized words",
30
+ "you": "You",
31
+ "youHearing": "You · Hearing…",
32
+ "youNotSent": "You · Not sent",
33
+ "latestAnswer": "{target} latest answer"
34
+ },
35
+ "controls": {
36
+ "label": "{target} voice chat controls",
37
+ "sendOrDiscard": "Send or discard speech to send text.",
38
+ "listening": "Listening…",
39
+ "recordingFinish": "Recording · finish speech to send text.",
40
+ "finishSpeech": "Finish speech to send text.",
41
+ "connecting": "Connecting…",
42
+ "releaseToSend": "Release to send",
43
+ "pause": "Pause",
44
+ "talk": "Talk",
45
+ "notSent": "Not sent · {words}",
46
+ "soundBlocked": "Sound is blocked. Enable sound to hear future replies.",
47
+ "enableSound": "Enable sound",
48
+ "review": "Review voice message",
49
+ "reviewMessage": "Review your message",
50
+ "discard": "Discard",
51
+ "sending": "Sending…",
52
+ "send": "Send",
53
+ "stopTargetSpeaking": "Stop {target} speaking",
54
+ "stopSpeaking": "Stop speaking",
55
+ "talkHint": "click or long press to talk",
56
+ "readAloudOff": "Turn {target} read-aloud off",
57
+ "readAloudOn": "Read {target} answers aloud",
58
+ "spokenRepliesOn": "Spoken replies on",
59
+ "spokenRepliesOff": "Spoken replies off",
60
+ "tapToPause": "Tap to pause · hold to speak",
61
+ "tapForHandsFree": "Tap for hands-free · hold to speak"
62
+ },
63
+ "settings": {
64
+ "title": "Voice settings",
65
+ "speakingVoice": "Speaking voice",
66
+ "speakingVoiceHint": "Applies to the next spoken reply"
67
+ },
68
+ "avatar": {
69
+ "label": "Assistant avatar"
70
+ },
71
+ "status": {
72
+ "interrupted": "Voice interrupted",
73
+ "needsAttention": "Voice needs attention",
74
+ "starting": "Starting voice…",
75
+ "active": "Voice active",
76
+ "off": "Voice off",
77
+ "reconnecting": "Reconnecting…",
78
+ "connecting": "Connecting…",
79
+ "openingMicrophone": "Opening microphone…",
80
+ "openingMic": "Opening mic…",
81
+ "listeningToYou": "Listening to you",
82
+ "listening": "Listening",
83
+ "targetSpeaking": "{target} is speaking",
84
+ "speaking": "Speaking",
85
+ "preparingSpeech": "Preparing speech…",
86
+ "thinking": "Thinking",
87
+ "sending": "Sending your message…",
88
+ "review": "Review your message below",
89
+ "microphoneMuted": "Microphone muted",
90
+ "transcribing": "Transcribing…",
91
+ "holdToSpeak": "Hold to speak",
92
+ "preparingMicrophone": "Preparing microphone…",
93
+ "live": "Live conversation"
94
+ },
95
+ "narration": {
96
+ "murmur": "Hmm..."
97
+ },
98
+ "speech": {
99
+ "codeOnScreen": "I put the code on screen.",
100
+ "sqlOnScreen": "I put the SQL on screen.",
101
+ "detailsInChat": "The details are in the chat.",
102
+ "image": "an image",
103
+ "link": "a link"
104
+ },
105
+ "errors": {
106
+ "notAccepted": "The conversation did not accept this message. Review it before retrying.",
107
+ "setupTimeout": "Voice setup took too long. Try Talk again.",
108
+ "finishAndReview": "{message} Tap the microphone to finish and review this recording.",
109
+ "microphoneNotReady": "The microphone was not ready. Hold the avatar again to record.",
110
+ "recordingInterrupted": "The connection interrupted this recording. These words may be incomplete. Review before sending, or discard and record again.",
111
+ "noSpeech": "No speech was recognized. Try again.",
112
+ "couldNotContinue": "Voice could not continue.",
113
+ "interruptedRecording": "Voice connection was interrupted. Your unfinished recording needs review; use Talk to resume.",
114
+ "interrupted": "Voice connection was interrupted. The answer remains in chat; use Talk to resume.",
115
+ "speechStalled": "Speech generation stalled. The answer remains in chat; use Talk to resume.",
116
+ "notConnected": "Voice is not connected.",
117
+ "playbackUnsupported": "This browser does not support streamed audio playback.",
118
+ "soundBlocked": "Sound is blocked by this browser.",
119
+ "busy": "Voice is busy. Try again shortly.",
120
+ "serviceCouldNotContinue": "Voice service could not continue.",
121
+ "invalidResponse": "Voice service sent an invalid response.",
122
+ "conversationRequired": "Voice requires an available conversation.",
123
+ "connectTimeout": "Voice service took too long to connect.",
124
+ "couldNotConnect": "Voice could not connect. Try again.",
125
+ "unreachable": "Voice service could not be reached.",
126
+ "closedWhileConnecting": "Voice service closed while connecting.",
127
+ "microphoneInUse": "Finish the recording in the other conversation before starting this microphone.",
128
+ "microphoneBehind": "The microphone connection fell behind. Review the unfinished recording before sending.",
129
+ "microphoneDenied": "Microphone access was denied. Allow it in your browser to talk to the assistant.",
130
+ "microphoneUnavailable": "The microphone could not be opened on this device.",
131
+ "pageSuspended": "Voice paused when this page was suspended. Review any unfinished words and use Talk to resume.",
132
+ "speechNotConfigured": "A speech service is not configured for this conversation.",
133
+ "noLongerAvailable": "This conversation is no longer available for voice.",
134
+ "hostDisposed": "The voice host has been disposed.",
135
+ "notAvailable": "This conversation is not available for voice.",
136
+ "finishBeforeEnding": "Finish or discard your recording before ending voice."
137
+ },
138
+ "protocol": {
139
+ "chooseVoice": "Choose an available voice before starting speech."
140
+ },
141
+ "daemon": {
142
+ "operationFailed": "Voice operation failed.",
143
+ "speechFailed": "Speech could not be generated.",
144
+ "queueClosing": "Voice speech queue is shutting down.",
145
+ "queueUnavailable": "Voice speech queue is unavailable.",
146
+ "capacityBusy": "Voice speech capacity is currently busy. Try again shortly.",
147
+ "speechTooFast": "Speech is arriving faster than playback.",
148
+ "audioWithoutRecording": "Audio arrived without an active recording.",
149
+ "noRecording": "No matching voice recording is active.",
150
+ "voiceUnavailable": "This voice is unavailable. Choose another voice."
151
+ },
152
+ "proxy": {
153
+ "voicesUnavailable": "Speaking voices could not load. Check the speech service and retry.",
154
+ "notInstalled": "Voice is not installed on this server.",
155
+ "unreachable": "Voice service could not be reached.",
156
+ "busy": "Voice is busy. Try again shortly.",
157
+ "sessionFailed": "Voice could not open for this conversation."
158
+ }
159
+ }
160
+ },
161
+ "errors": {
162
+ "voice_turn_id_invalid": "Voice control messages require a valid turn ID.",
163
+ "voice_control_size_invalid": "Voice control message size is invalid.",
164
+ "voice_control_json_invalid": "Voice control messages must be valid JSON.",
165
+ "voice_control_object_required": "Voice control messages must be JSON objects.",
166
+ "voice_control_type_invalid": "Unsupported voice control type: {type}.",
167
+ "voice_input_sample_rate_invalid": "Voice input must be {sampleRate} Hz mono PCM.",
168
+ "voice_segment_invalid": "Choose the current spoken phrase.",
169
+ "voice_revision_invalid": "Choose the current recognized utterance.",
170
+ "voice_speech_text_invalid": "Speech text must contain 1-{maximum} characters.",
171
+ "voice_audio_frame_invalid": "Voice audio frames must contain bounded 16-bit mono PCM.",
172
+ "voice_utterance_too_long": "Voice recordings are limited to {seconds} seconds.",
173
+ "voice_recognition_backpressure": "Speech recognition fell behind. Your recording may be incomplete; review the recognized words.",
174
+ "voice_speech_not_active": "No matching speech stream is open.",
175
+ "voice_access_revoked": "This application's voice access was revoked.",
176
+ "voice_playback_backpressure": "Voice playback fell behind. Speech stopped; the answer remains in chat.",
177
+ "voice_auth_required": "Voice access was denied.",
178
+ "voice_frame_too_large": "Voice message is too large.",
179
+ "voice_connecting": "Voice is still connecting. Try again."
180
+ }
181
+ }
182
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/assistant-voice",
3
- "version": "0.1.45",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Duplex voice conversations with application-owned targets, authorization and speech services.",
6
6
  "scripts": {
@@ -10,15 +10,17 @@
10
10
  "./client": "./src/client/index.js",
11
11
  "./server": "./src/server/index.js",
12
12
  "./shared/protocol": "./src/shared/protocol.js",
13
- "./shared/visemes": "./src/shared/visemes.js"
13
+ "./shared/visemes": "./src/shared/visemes.js",
14
+ "./locales/en.json": "./locales/en.json"
14
15
  },
15
16
  "files": [
16
17
  "src",
18
+ "locales",
17
19
  "README.md",
18
20
  "examples"
19
21
  ],
20
22
  "dependencies": {
21
- "@jskit-ai/assistant-core": "0.1.244",
23
+ "@jskit-ai/assistant-core": "0.2.0",
22
24
  "@mdi/js": "^7.4.47",
23
25
  "ws": "^8.20.1"
24
26
  },
@@ -61,6 +63,7 @@
61
63
  }
62
64
  },
63
65
  "peerDependencies": {
66
+ "@jskit-ai/kernel": "0.2.0",
64
67
  "vue": "^3.5.13",
65
68
  "vuetify": "^4.0.0"
66
69
  },
@@ -3,17 +3,19 @@ import { mdiClose, mdiMessageTextOutline, mdiMicrophone, mdiMinus } from "@mdi/j
3
3
  import { useDisplay } from "vuetify";
4
4
  import { VCard, VDialog } from "vuetify/components";
5
5
  import { computed } from "vue";
6
+ import { useJskitText } from "./i18n.js";
6
7
 
7
8
  const { xs } = useDisplay();
9
+ const { t } = useJskitText();
8
10
 
9
11
  const props = defineProps({
10
12
  modelValue: Boolean,
11
13
  activator: { type: Object, default: null },
12
- title: { type: String, default: "Assistant" },
14
+ title: { type: String, default: "" },
13
15
  mode: { type: String, default: "talk" },
14
16
  showModes: Boolean,
15
17
  minimizable: Boolean,
16
- closeLabel: { type: String, default: "Close conversation" },
18
+ closeLabel: { type: String, default: "" },
17
19
  presentation: { type: String, default: "dialog", validator: value => ["dialog", "inline"].includes(value) }
18
20
  });
19
21
  const dialogProps = computed(() => props.presentation === "inline" ? {} : {
@@ -24,6 +26,8 @@ const dialogProps = computed(() => props.presentation === "inline" ? {} : {
24
26
  contentProps: { style: { margin: xs.value ? 0 : "16px" } },
25
27
  "aria-hidden": !props.modelValue
26
28
  });
29
+ const displayTitle = computed(() => props.title || t("jskit.assistant.voice.assistant"));
30
+ const displayCloseLabel = computed(() => props.closeLabel || t("jskit.assistant.voice.dialog.close"));
27
31
  const emit = defineEmits(["update:modelValue", "update:mode", "minimize"]);
28
32
  let dismissedFromActivator = false;
29
33
  function outsideClick(event) {
@@ -42,19 +46,25 @@ function updateOpen(value) {
42
46
  <template>
43
47
  <component
44
48
  :is="presentation === 'inline' ? 'section' : VDialog" v-bind="dialogProps"
45
- class="conversation-dialog" :class="{ 'conversation-dialog--inline': presentation === 'inline' }" :aria-label="`${title} conversation`"
49
+ class="conversation-dialog" :class="{ 'conversation-dialog--inline': presentation === 'inline' }" :aria-label="t('jskit.assistant.voice.dialog.label', { title: displayTitle })"
46
50
  @click:outside="outsideClick" @update:model-value="updateOpen"
47
51
  >
48
52
  <component :is="presentation === 'inline' ? 'div' : VCard" class="conversation-dialog__surface" :rounded="presentation === 'inline' ? undefined : xs ? 0 : 'lg'">
49
53
  <v-card-title v-if="presentation !== 'inline'" class="conversation-dialog__title text-title-large">
50
- <span :title="title">{{ title }}</span>
54
+ <span :title="displayTitle">{{ displayTitle }}</span>
51
55
  <slot name="header-actions" />
52
- <v-btn v-if="minimizable" :icon="mdiMinus" variant="text" aria-label="Minimize conversation" title="Minimize conversation" @click="$emit('minimize', $event)" />
53
- <v-btn :icon="mdiClose" variant="text" :aria-label="closeLabel" :title="closeLabel" @click="$emit('update:modelValue', false)" />
56
+ <v-btn
57
+ v-if="minimizable" :icon="mdiMinus" variant="text" :aria-label="t('jskit.assistant.voice.dialog.minimize')"
58
+ :title="t('jskit.assistant.voice.dialog.minimize')" @click="$emit('minimize', $event)"
59
+ />
60
+ <v-btn :icon="mdiClose" variant="text" :aria-label="displayCloseLabel" :title="displayCloseLabel" @click="$emit('update:modelValue', false)" />
54
61
  </v-card-title>
55
- <v-tabs v-if="showModes" :model-value="mode" class="conversation-dialog__tabs" grow aria-label="Conversation mode" @update:model-value="$emit('update:mode', $event)">
56
- <v-tab value="talk" :prepend-icon="mdiMicrophone">Talk</v-tab>
57
- <v-tab value="text" :prepend-icon="mdiMessageTextOutline">Text</v-tab>
62
+ <v-tabs
63
+ v-if="showModes" :model-value="mode" class="conversation-dialog__tabs" grow :aria-label="t('jskit.assistant.voice.dialog.modes')"
64
+ @update:model-value="$emit('update:mode', $event)"
65
+ >
66
+ <v-tab value="talk" :prepend-icon="mdiMicrophone">{{ t("jskit.assistant.voice.dialog.talk") }}</v-tab>
67
+ <v-tab value="text" :prepend-icon="mdiMessageTextOutline">{{ t("jskit.assistant.voice.dialog.text") }}</v-tab>
58
68
  </v-tabs>
59
69
  <div class="conversation-dialog__body"><slot /></div>
60
70
  </component>
@@ -1,12 +1,14 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
3
  import { useVoiceAvatar } from "./voiceAvatar.js";
4
+ import { useJskitText } from "./i18n.js";
4
5
  const props = defineProps({ state: { type: String, default: "idle" }, mouthPose: { type: String, default: "closed" }, mouthLevel: { type: Number, default: 0 } });
5
6
  const { blinking, visibleMouthPose, reducedMotion } = useVoiceAvatar(props);
7
+ const { t } = useJskitText();
6
8
  const mouthHeight = computed(() => reducedMotion.value || visibleMouthPose.value === "closed" ? 3 : Math.max(4, Math.min(18, props.mouthLevel * 28)));
7
9
  </script>
8
10
  <template>
9
- <svg viewBox="0 0 128 128" aria-label="Assistant avatar" role="img" class="voice-avatar">
11
+ <svg viewBox="0 0 128 128" :aria-label="t('jskit.assistant.voice.avatar.label')" role="img" class="voice-avatar">
10
12
  <circle cx="64" cy="64" r="59" fill="currentColor" opacity=".1" />
11
13
  <rect x="25" y="31" width="78" height="66" rx="24" fill="none" stroke="currentColor" stroke-width="3" />
12
14
  <path d="M64 31V21" stroke="currentColor" stroke-width="3" />
@@ -4,6 +4,7 @@ import { AssistantConversationElement } from "@jskit-ai/assistant-core/client/co
4
4
  import VoiceAvatar from "./VoiceAvatar.vue";
5
5
  import VoiceConversationControls from "./VoiceConversationControls.vue";
6
6
  import { mdiMicrophone, mdiVolumeHigh } from "@mdi/js";
7
+ import { useJskitText } from "./i18n.js";
7
8
 
8
9
  const props = defineProps({
9
10
  session: { type: Object, required: true }, disabled: { type: Boolean, default: false },
@@ -12,6 +13,7 @@ const props = defineProps({
12
13
  avatarSize: { type: String, default: "compact" }
13
14
  });
14
15
  defineEmits(["update:avatarSize"]);
16
+ const { t } = useJskitText();
15
17
  const { targetLabel, voice, microphoneMuted, heldTranscript, pendingTranscript, sending,
16
18
  avatarVisual, callAudioLevel, voiceWords, voiceAnswer } = props.session;
17
19
  const presentationAdapter = computed(() => props.adapter && ({
@@ -23,6 +25,11 @@ const voiceWordsTarget = ref(null);
23
25
  const voiceAnswerTarget = ref(null);
24
26
  const followWords = ref(true);
25
27
  const followAnswer = ref(true);
28
+ const youLabel = computed(() => {
29
+ if (heldTranscript.value && voice.listening.value && !microphoneMuted.value) return t("jskit.assistant.voice.conversation.youHearing");
30
+ if (pendingTranscript.value && !sending.value) return t("jskit.assistant.voice.conversation.youNotSent");
31
+ return t("jskit.assistant.voice.conversation.you");
32
+ });
26
33
  function isAtBottom(element) { return element.scrollHeight - element.scrollTop - element.clientHeight < 24; }
27
34
  for (const [text, target, following] of [[voiceWords, voiceWordsTarget, followWords], [voiceAnswer, voiceAnswerTarget, followAnswer]]) {
28
35
  watch(text, () => {
@@ -42,10 +49,16 @@ for (const [text, target, following] of [[voiceWords, voiceWordsTarget, followWo
42
49
  <template v-if="showAvatar" #avatar-tools><div ref="toolsTarget" class="assistant-voice-conversation__tools" /></template>
43
50
  <template #avatar-control="scope">
44
51
  <slot name="avatar-control" v-bind="scope">
45
- <span v-if="scope.size === 'hidden' && voice.listening.value && !microphoneMuted" role="img" aria-label="Listening" title="Listening">
52
+ <span
53
+ v-if="scope.size === 'hidden' && voice.listening.value && !microphoneMuted" role="img"
54
+ :aria-label="t('jskit.assistant.voice.conversation.listening')" :title="t('jskit.assistant.voice.conversation.listening')"
55
+ >
46
56
  <v-icon :icon="mdiMicrophone" size="20" aria-hidden="true" />
47
57
  </span>
48
- <span v-if="scope.size === 'hidden' && voice.speaking.value" role="img" aria-label="Speaking" title="Speaking">
58
+ <span
59
+ v-if="scope.size === 'hidden' && voice.speaking.value" role="img"
60
+ :aria-label="t('jskit.assistant.voice.conversation.speaking')" :title="t('jskit.assistant.voice.conversation.speaking')"
61
+ >
49
62
  <v-icon :icon="mdiVolumeHigh" size="20" aria-hidden="true" />
50
63
  </span>
51
64
  </slot>
@@ -61,19 +74,25 @@ for (const [text, target, following] of [[voiceWords, voiceWordsTarget, followWo
61
74
  <fieldset v-else class="assistant-voice" :disabled="disabled">
62
75
  <section
63
76
  class="assistant-voice__call" :class="{ 'assistant-voice__call--without-avatar': !showAvatar }"
64
- :aria-label="`${targetLabel} voice chat controls`"
77
+ :aria-label="t('jskit.assistant.voice.controls.label', { target: targetLabel })"
65
78
  >
66
79
  <div v-if="showAvatar" class="assistant-voice__call-body">
67
80
  <div class="assistant-voice__call-portrait" :style="{ '--call-audio-scale': 1 + callAudioLevel * .16 }" aria-hidden="true">
68
81
  <slot name="avatar" v-bind="avatarVisual"><VoiceAvatar v-bind="avatarVisual" /></slot>
69
82
  </div>
70
83
  </div>
71
- <div class="assistant-voice__captions" aria-label="Voice conversation text">
72
- <section ref="voiceWordsTarget" class="assistant-voice__caption" aria-label="Recognized words" tabindex="0" @scroll="followWords = isAtBottom($event.currentTarget)">
73
- <strong class="text-label-medium">You<span v-if="heldTranscript && voice.listening.value && !microphoneMuted"> · Hearing…</span><span v-else-if="pendingTranscript && !sending"> · Not sent</span></strong>
84
+ <div class="assistant-voice__captions" :aria-label="t('jskit.assistant.voice.conversation.captions')">
85
+ <section
86
+ ref="voiceWordsTarget" class="assistant-voice__caption" :aria-label="t('jskit.assistant.voice.conversation.recognizedWords')" tabindex="0"
87
+ @scroll="followWords = isAtBottom($event.currentTarget)"
88
+ >
89
+ <strong class="text-label-medium">{{ youLabel }}</strong>
74
90
  <p class="assistant-voice__caption-text text-body-medium">{{ voiceWords }}</p>
75
91
  </section>
76
- <section ref="voiceAnswerTarget" class="assistant-voice__caption" :aria-label="`${targetLabel} latest answer`" tabindex="0" @scroll="followAnswer = isAtBottom($event.currentTarget)">
92
+ <section
93
+ ref="voiceAnswerTarget" class="assistant-voice__caption" :aria-label="t('jskit.assistant.voice.conversation.latestAnswer', { target: targetLabel })"
94
+ tabindex="0" @scroll="followAnswer = isAtBottom($event.currentTarget)"
95
+ >
77
96
  <strong class="text-label-medium">{{ targetLabel }}</strong>
78
97
  <p class="assistant-voice__caption-text text-body-medium">{{ voiceAnswer }}</p>
79
98
  </section>
@@ -2,6 +2,7 @@
2
2
  import { computed, useId } from "vue";
3
3
  import { mdiMicrophone, mdiMicrophoneOff, mdiStop, mdiVolumeHigh, mdiVolumeOff } from "@mdi/js";
4
4
  import { useVoiceLauncher } from "./voiceLauncher.js";
5
+ import { useJskitText, voiceErrorText } from "./i18n.js";
5
6
 
6
7
  const props = defineProps({
7
8
  session: { type: Object, required: true },
@@ -20,22 +21,25 @@ const {
20
21
  stopSpeech, startPushToTalk, finishPushToTalk, cancelPushToTalk, toggleHandsFree, readAloud, toggleReadAloud, enableSound,
21
22
  deliverTranscript, discardHeldRecording, editTranscript
22
23
  } = props.session;
24
+ const { t } = useJskitText();
23
25
  const controlStatus = computed(() => {
24
26
  if (props.iconOnly && voice.listening.value && !starting.value && !error.value && !voice.error.value) return "";
25
27
  if (!props.compact || !props.session.hasUnsentSpeech.value) return callStatus.value;
26
- if (pendingTranscript.value) return props.reviewInTranscript ? "" : "Send or discard speech to send text.";
27
- if (live.value && callMode.value === "hands-free" && voice.listening.value && !microphoneMuted.value) return "Listening…";
28
- return voice.listening.value ? "Recording · finish speech to send text." : "Finish speech to send text.";
28
+ if (pendingTranscript.value) return props.reviewInTranscript ? "" : t("jskit.assistant.voice.controls.sendOrDiscard");
29
+ if (live.value && callMode.value === "hands-free" && voice.listening.value && !microphoneMuted.value) return t("jskit.assistant.voice.controls.listening");
30
+ return voice.listening.value ? t("jskit.assistant.voice.controls.recordingFinish") : t("jskit.assistant.voice.controls.finishSpeech");
29
31
  });
30
32
  const handsFreeListening = computed(() => live.value && callMode.value === "hands-free" && voice.listening.value && !microphoneMuted.value);
31
33
  const canTalk = computed(() => !props.disabled && (!capturing.value || voice.listening.value || pushHolding.value || starting.value));
32
- const talkLabel = computed(() => starting.value ? "Connecting…" : pushHolding.value ? "Release to send" : handsFreeListening.value ? "Pause" : "Talk");
34
+ const talkLabel = computed(() => t(starting.value ? "jskit.assistant.voice.controls.connecting"
35
+ : pushHolding.value ? "jskit.assistant.voice.controls.releaseToSend"
36
+ : handsFreeListening.value ? "jskit.assistant.voice.controls.pause" : "jskit.assistant.voice.controls.talk"));
33
37
  const gestureHint = useId();
34
38
  const gesture = useVoiceLauncher({
35
39
  enabled: canTalk,
36
40
  open: () => ({ startHeldRecording: startPushToTalk, finishHeldRecording: finishPushToTalk, discardHeldRecording: cancelPushToTalk }),
37
41
  onTap: toggleHandsFree,
38
- onError: cause => { error.value = cause.message; }
42
+ onError: cause => { error.value = voiceErrorText(cause); }
39
43
  });
40
44
  </script>
41
45
 
@@ -50,26 +54,40 @@ const gesture = useVoiceLauncher({
50
54
  {{ error || voice.error.value }}
51
55
  </p>
52
56
  <p v-if="controlStatus" class="assistant-voice-controls__status text-body-small" role="status" :title="callStatus">{{ controlStatus }}</p>
53
- <p v-if="compact && !reviewInTranscript && heldTranscript && !pendingTranscript" class="assistant-voice-controls__provisional" role="status" aria-label="Recognized words">Not sent · {{ heldTranscript }}</p>
54
- <p v-if="readAloud && voice.playbackBlocked?.value" class="assistant-voice-controls__status" role="status">Sound is blocked. Enable sound to hear future replies.</p>
55
- <v-btn v-if="readAloud && voice.playbackBlocked?.value" min-height="48" @click="enableSound">Enable sound</v-btn>
56
- <section v-if="!reviewInTranscript && pendingTranscript && (pendingTranscript.reviewBeforeSend || !sending)" class="assistant-voice__review" aria-label="Review voice message">
57
+ <p
58
+ v-if="compact && !reviewInTranscript && heldTranscript && !pendingTranscript" class="assistant-voice-controls__provisional" role="status"
59
+ :aria-label="t('jskit.assistant.voice.conversation.recognizedWords')"
60
+ >
61
+ {{ t("jskit.assistant.voice.controls.notSent", { words: heldTranscript }) }}
62
+ </p>
63
+ <p v-if="readAloud && voice.playbackBlocked?.value" class="assistant-voice-controls__status" role="status">{{ t("jskit.assistant.voice.controls.soundBlocked") }}</p>
64
+ <v-btn v-if="readAloud && voice.playbackBlocked?.value" min-height="48" @click="enableSound">{{ t("jskit.assistant.voice.controls.enableSound") }}</v-btn>
65
+ <section
66
+ v-if="!reviewInTranscript && pendingTranscript && (pendingTranscript.reviewBeforeSend || !sending)" class="assistant-voice__review"
67
+ :aria-label="t('jskit.assistant.voice.controls.review')"
68
+ >
57
69
  <v-textarea
58
- class="assistant-voice__review-input" :model-value="pendingTranscript.text" label="Review your message" :disabled="sending"
70
+ class="assistant-voice__review-input" :model-value="pendingTranscript.text" :label="t('jskit.assistant.voice.controls.reviewMessage')" :disabled="sending"
59
71
  :density="compact ? 'compact' : 'default'" :rows="compact ? 1 : 2" :max-rows="compact ? 2 : 3"
60
72
  auto-grow hide-details @update:model-value="editTranscript"
61
73
  />
62
74
  <div class="assistant-voice__review-actions">
63
- <v-btn :disabled="sending" min-height="48" @click="discardHeldRecording">Discard</v-btn>
64
- <v-btn :disabled="sending || !pendingTranscript.text.trim()" min-height="48" color="primary" @click="deliverTranscript">{{ sending ? 'Sending…' : 'Send' }}</v-btn>
75
+ <v-btn :disabled="sending" min-height="48" @click="discardHeldRecording">{{ t("jskit.assistant.voice.controls.discard") }}</v-btn>
76
+ <v-btn :disabled="sending || !pendingTranscript.text.trim()" min-height="48" color="primary" @click="deliverTranscript">
77
+ {{ sending ? t("jskit.assistant.voice.controls.sending") : t("jskit.assistant.voice.controls.send") }}
78
+ </v-btn>
65
79
  </div>
66
80
  </section>
67
81
  </fieldset>
68
82
  </Teleport>
69
83
  <Teleport :to="toolsTarget" :disabled="!toolsTarget">
70
- <fieldset class="assistant-voice-controls__tools" :class="{ 'assistant-voice-controls__tools--compact': compact, 'assistant-voice-controls__tools--icons': iconOnly }" :disabled="disabled" :aria-label="`${targetLabel} voice chat controls`">
84
+ <fieldset class="assistant-voice-controls__tools" :class="{ 'assistant-voice-controls__tools--compact': compact, 'assistant-voice-controls__tools--icons': iconOnly }" :disabled="disabled" :aria-label="t('jskit.assistant.voice.controls.label', { target: targetLabel })">
71
85
  <div v-if="compact || iconOnly || speechActive" class="assistant-voice-controls__stop">
72
- <v-btn v-if="speechActive" :icon="mdiStop" variant="text" min-width="48" min-height="48" :aria-label="`Stop ${targetLabel} speaking`" title="Stop speaking" @click="stopSpeech" />
86
+ <v-btn
87
+ v-if="speechActive" :icon="mdiStop" variant="text" min-width="48" min-height="48"
88
+ :aria-label="t('jskit.assistant.voice.controls.stopTargetSpeaking', { target: targetLabel })"
89
+ :title="t('jskit.assistant.voice.controls.stopSpeaking')" @click="stopSpeech"
90
+ />
73
91
  </div>
74
92
  <slot name="work-control" />
75
93
  <div class="assistant-voice__talk-action">
@@ -77,7 +95,7 @@ const gesture = useVoiceLauncher({
77
95
  class="assistant-voice__talk" color="primary" :variant="iconOnly ? 'text' : handsFreeListening ? 'tonal' : 'flat'" :min-height="iconOnly ? 44 : compact ? 48 : 64" rounded="xl"
78
96
  :icon="iconOnly ? (voice.listening.value && !microphoneMuted ? mdiMicrophone : mdiMicrophoneOff) : undefined"
79
97
  :prepend-icon="iconOnly ? undefined : (voice.listening.value && !microphoneMuted ? mdiMicrophone : mdiMicrophoneOff)"
80
- :aria-label="iconOnly ? talkLabel : undefined" title="click or long press to talk"
98
+ :aria-label="iconOnly ? talkLabel : undefined" :title="t('jskit.assistant.voice.controls.talkHint')"
81
99
  :aria-pressed="handsFreeListening || pushHolding" :aria-describedby="gestureHint"
82
100
  :disabled="!canTalk" :slim="compact || iconOnly"
83
101
  :width="iconOnly ? 40 : compact ? 148 : undefined" :min-width="iconOnly ? 40 : compact ? 148 : undefined"
@@ -90,8 +108,10 @@ const gesture = useVoiceLauncher({
90
108
  </v-btn>
91
109
  <v-btn
92
110
  :icon="readAloud ? mdiVolumeHigh : mdiVolumeOff" :aria-pressed="readAloud" :variant="iconOnly ? 'text' : 'tonal'" :color="iconOnly ? 'primary' : undefined" :min-height="iconOnly ? 44 : compact ? 48 : 64" :width="iconOnly ? 40 : undefined" :min-width="iconOnly ? 40 : compact ? 48 : 64" rounded="xl"
93
- :aria-label="readAloud ? `Turn ${targetLabel} read-aloud off` : `Read ${targetLabel} answers aloud`"
94
- :title="readAloud ? 'Spoken replies on' : 'Spoken replies off'"
111
+ :aria-label="readAloud
112
+ ? t('jskit.assistant.voice.controls.readAloudOff', { target: targetLabel })
113
+ : t('jskit.assistant.voice.controls.readAloudOn', { target: targetLabel })"
114
+ :title="readAloud ? t('jskit.assistant.voice.controls.spokenRepliesOn') : t('jskit.assistant.voice.controls.spokenRepliesOff')"
95
115
  :disabled="speakerDisabled || session.readAloudChangePending?.value === true" @click="toggleReadAloud"
96
116
  >
97
117
  <template v-if="iconOnly" #default>
@@ -99,7 +119,9 @@ const gesture = useVoiceLauncher({
99
119
  </template>
100
120
  </v-btn>
101
121
  <slot name="settings-control" />
102
- <p :id="gestureHint" class="text-body-small text-medium-emphasis">{{ handsFreeListening ? 'Tap to pause · hold to speak' : 'Tap for hands-free · hold to speak' }}</p>
122
+ <p :id="gestureHint" class="text-body-small text-medium-emphasis">
123
+ {{ handsFreeListening ? t("jskit.assistant.voice.controls.tapToPause") : t("jskit.assistant.voice.controls.tapForHandsFree") }}
124
+ </p>
103
125
  </div>
104
126
  </fieldset>
105
127
  </Teleport>
@@ -3,6 +3,7 @@ import { mdiHeadset, mdiStop } from "@mdi/js";
3
3
  import ConversationDialog from "./ConversationDialog.vue";
4
4
  import VoiceConversation from "./VoiceConversation.vue";
5
5
  import VoiceConversationSettings from "./VoiceConversationSettings.vue";
6
+ import { useJskitText, voiceErrorText } from "./i18n.js";
6
7
 
7
8
  const props = defineProps({
8
9
  controller: { type: Object, required: true }, activator: { type: Object, default: null },
@@ -10,10 +11,11 @@ const props = defineProps({
10
11
  presentation: { type: String, default: "dialog", validator: value => ["dialog", "inline"].includes(value) }
11
12
  });
12
13
  defineEmits(["update:avatarSize"]);
14
+ const { t } = useJskitText();
13
15
  const state = props.controller.state;
14
16
  async function invoke(operation) {
15
17
  try { await operation(); }
16
- catch (error) { state.error = error.message; }
18
+ catch (error) { state.error = voiceErrorText(error); }
17
19
  }
18
20
  async function openText() {
19
21
  const opening = state.binding.openText();
@@ -26,23 +28,30 @@ async function openText() {
26
28
  <template>
27
29
  <ConversationDialog
28
30
  v-if="state.session" :model-value="state.visible" :activator="activator" :presentation="presentation"
29
- :title="state.binding.label || 'Assistant'" mode="talk"
31
+ :title="state.binding.label || t('jskit.assistant.voice.assistant')" mode="talk"
30
32
  :show-modes="Boolean(state.binding.openText && !state.binding.adapter)"
31
- :minimizable="presentation === 'dialog'" close-label="Close voice chat" @minimize="controller.minimize()" @update:model-value="invoke(() => controller.end({ discard: true }))"
33
+ :minimizable="presentation === 'dialog'" :close-label="t('jskit.assistant.voice.host.close')" @minimize="controller.minimize()" @update:model-value="invoke(() => controller.end({ discard: true }))"
32
34
  @update:mode="value => value === 'text' && invoke(openText)"
33
35
  >
34
36
  <template v-if="!state.binding.adapter" #header-actions>
35
- <VoiceConversationSettings :voice="state.session.voice" @error="state.error = $event.message">
37
+ <VoiceConversationSettings :voice="state.session.voice" @error="state.error = voiceErrorText($event)">
36
38
  <template v-if="$slots.settings" #default="settings"><slot name="settings" v-bind="settings" /></template>
37
39
  </VoiceConversationSettings>
38
40
  </template>
39
41
  <v-alert v-if="state.error" type="error" density="compact" role="alert">{{ state.error }}</v-alert>
40
42
  <v-alert v-if="state.nextTarget" type="info" class="voice-host__switch">
41
- Finish or discard your recording for {{ state.binding.label || 'this conversation' }} before switching to {{ state.nextTarget.label || 'another conversation' }}.
43
+ {{ t("jskit.assistant.voice.host.switchPrompt", {
44
+ current: state.binding.label || t("jskit.assistant.voice.host.thisConversation"),
45
+ next: state.nextTarget.label || t("jskit.assistant.voice.host.anotherConversation")
46
+ }) }}
42
47
  <div class="voice-host__switch-actions">
43
- <v-btn variant="text" @click="controller.cancelSwitch()">Stay here</v-btn>
44
- <v-btn :disabled="state.busy || state.session.sending.value" variant="text" @click="invoke(() => controller.switchTarget({ discard: true }))">Discard and switch</v-btn>
45
- <v-btn v-if="!state.session.hasUnsentSpeech.value" :disabled="state.busy" variant="text" @click="invoke(() => controller.switchTarget())">Switch</v-btn>
48
+ <v-btn variant="text" @click="controller.cancelSwitch()">{{ t("jskit.assistant.voice.host.stayHere") }}</v-btn>
49
+ <v-btn :disabled="state.busy || state.session.sending.value" variant="text" @click="invoke(() => controller.switchTarget({ discard: true }))">
50
+ {{ t("jskit.assistant.voice.host.discardAndSwitch") }}
51
+ </v-btn>
52
+ <v-btn v-if="!state.session.hasUnsentSpeech.value" :disabled="state.busy" variant="text" @click="invoke(() => controller.switchTarget())">
53
+ {{ t("jskit.assistant.voice.host.switch") }}
54
+ </v-btn>
46
55
  </div>
47
56
  </v-alert>
48
57
  <div class="voice-host__body">
@@ -55,12 +64,15 @@ async function openText() {
55
64
  <template v-if="$slots.avatar" #avatar="visual"><slot name="avatar" v-bind="visual" :binding="state.binding" /></template>
56
65
  <template v-if="$slots['avatar-control']" #avatar-control="scope"><slot name="avatar-control" v-bind="scope" :binding="state.binding" :session="state.session" /></template>
57
66
  <template v-if="presentation === 'inline' || state.binding.adapter" #settings-control>
58
- <VoiceConversationSettings :voice="state.session.voice" compact @error="state.error = $event.message">
67
+ <VoiceConversationSettings :voice="state.session.voice" compact @error="state.error = voiceErrorText($event)">
59
68
  <template v-if="$slots.settings" #default="settings"><slot name="settings" v-bind="settings" /></template>
60
69
  </VoiceConversationSettings>
61
70
  </template>
62
71
  <template #work-control>
63
- <v-btn v-if="state.binding.cancelWork && state.binding.state.status === 'working'" :disabled="state.busy" :icon="mdiStop" variant="text" aria-label="Stop agent work" title="Stop agent work" @click="invoke(state.binding.cancelWork)" />
72
+ <v-btn
73
+ v-if="state.binding.cancelWork && state.binding.state.status === 'working'" :disabled="state.busy" :icon="mdiStop" variant="text"
74
+ :aria-label="t('jskit.assistant.voice.host.stopWork')" :title="t('jskit.assistant.voice.host.stopWork')" @click="invoke(state.binding.cancelWork)"
75
+ />
64
76
  </template>
65
77
  </VoiceConversation>
66
78
  </slot>
@@ -69,7 +81,7 @@ async function openText() {
69
81
  <template v-if="presentation === 'dialog' && state.session && !state.visible">
70
82
  <slot v-if="$slots.reopen" name="reopen" :controller="controller" />
71
83
  <v-btn v-else class="voice-host__reopen" color="primary" :prepend-icon="mdiHeadset" min-height="56" @click="controller.reveal()">
72
- {{ state.binding.label || 'Assistant' }} · Voice chat
84
+ {{ t("jskit.assistant.voice.host.reopen", { label: state.binding.label || t("jskit.assistant.voice.assistant") }) }}
73
85
  </v-btn>
74
86
  </template>
75
87
  </template>