Speak a confirmation when toggling PC audio
This commit is contained in:
@@ -23,6 +23,7 @@ export function quickAction(transcript) {
|
||||
name: 'pc_audio',
|
||||
args: { action: enabled ? 'start' : 'stop' },
|
||||
done: enabled ? 'Звук с компьютера включён.' : 'Звук с компьютера выключен.',
|
||||
speakOnSuccess: true,
|
||||
failure: 'Не удалось переключить звук с компьютера. Проверь агент на Windows.',
|
||||
success: result => result?.ok === true && result.enabled === enabled,
|
||||
};
|
||||
|
||||
+5
-2
@@ -51,10 +51,13 @@ export function handleTurn(client, store) {
|
||||
send({ type: 'transcript', text });
|
||||
try {
|
||||
const action = quickAction(text);
|
||||
let quickReply;
|
||||
if (action) {
|
||||
const result = await device.execute(action.name, action.args).catch(() => null);
|
||||
if (terminal) return;
|
||||
if (action.success(result)) return complete(text, action.done);
|
||||
const succeeded = action.success(result);
|
||||
if (succeeded && !action.speakOnSuccess) return complete(text, action.done);
|
||||
quickReply = succeeded ? action.done : action.failure;
|
||||
}
|
||||
tts = await openTts(settings, signal, audio => {
|
||||
if (terminal || client.readyState !== WebSocket.OPEN) return;
|
||||
@@ -62,7 +65,7 @@ export function handleTurn(client, store) {
|
||||
client.send(audio, { binary: true });
|
||||
});
|
||||
if (terminal) return;
|
||||
const answer = action?.failure ?? await streamAnswer(settings, store.getHistory(), text, signal, part => tts.text(part), device.execute);
|
||||
const answer = quickReply ?? await streamAnswer(settings, store.getHistory(), text, signal, part => tts.text(part), device.execute);
|
||||
if (action) tts.text(answer);
|
||||
tts.finish();
|
||||
await tts.done;
|
||||
|
||||
Reference in New Issue
Block a user