From 0c8277e550adf9e9f4049709f11b2c1e5b42b965 Mon Sep 17 00:00:00 2001 From: Simon Farshid Date: Mon, 14 Oct 2024 16:25:08 -0700 Subject: [PATCH] refactor!: simplify SpeechSynthesisAdapter to accept a text string (#1009) --- .changeset/selfish-snakes-drive.md | 5 +++++ packages/react/src/runtimes/speech/SpeechAdapterTypes.ts | 4 ++-- .../react/src/runtimes/speech/WebSpeechSynthesisAdapter.ts | 5 +---- 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .changeset/selfish-snakes-drive.md diff --git a/.changeset/selfish-snakes-drive.md b/.changeset/selfish-snakes-drive.md new file mode 100644 index 000000000..6229acbb3 --- /dev/null +++ b/.changeset/selfish-snakes-drive.md @@ -0,0 +1,5 @@ +--- +"@assistant-ui/react": patch +--- + +feat: MessageRuntime.unstable_getCopyText API diff --git a/packages/react/src/runtimes/speech/SpeechAdapterTypes.ts b/packages/react/src/runtimes/speech/SpeechAdapterTypes.ts index 93c01e487..5f8492541 100644 --- a/packages/react/src/runtimes/speech/SpeechAdapterTypes.ts +++ b/packages/react/src/runtimes/speech/SpeechAdapterTypes.ts @@ -1,4 +1,4 @@ -import { ThreadMessage, Unsubscribe } from "../../types"; +import { Unsubscribe } from "../../types"; export namespace SpeechSynthesisAdapter { export type Status = @@ -19,7 +19,7 @@ export namespace SpeechSynthesisAdapter { } export type SpeechSynthesisAdapter = { - speak: (message: ThreadMessage) => SpeechSynthesisAdapter.Utterance; + speak: (text: string) => SpeechSynthesisAdapter.Utterance; }; export namespace SpeechRecognitionAdapter { diff --git a/packages/react/src/runtimes/speech/WebSpeechSynthesisAdapter.ts b/packages/react/src/runtimes/speech/WebSpeechSynthesisAdapter.ts index e6fb9870c..065660f6e 100644 --- a/packages/react/src/runtimes/speech/WebSpeechSynthesisAdapter.ts +++ b/packages/react/src/runtimes/speech/WebSpeechSynthesisAdapter.ts @@ -1,10 +1,7 @@ -import { ThreadMessage } from "../../types"; -import { getThreadMessageText } from "../../utils/getThreadMessageText"; import { SpeechSynthesisAdapter } from "./SpeechAdapterTypes"; export class WebSpeechSynthesisAdapter implements SpeechSynthesisAdapter { - speak(message: ThreadMessage): SpeechSynthesisAdapter.Utterance { - const text = getThreadMessageText(message); + speak(text: string): SpeechSynthesisAdapter.Utterance { const utterance = new SpeechSynthesisUtterance(text); const subscribers = new Set<() => void>();