diff options
| author | Dhravya Shah <[email protected]> | 2024-08-02 09:47:23 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-08-02 09:47:23 -0700 |
| commit | e3348eda65cce7bd4aa397f42365e029018b77a4 (patch) | |
| tree | 44fb2ae3bccba408c6b1ec79d3e4255e218af082 /apps/web/app | |
| parent | send a sliced version to the API (diff) | |
| parent | Merge pull request #198 from krakenftw/textospeech (diff) | |
| download | supermemory-e3348eda65cce7bd4aa397f42365e029018b77a4.tar.xz supermemory-e3348eda65cce7bd4aa397f42365e029018b77a4.zip | |
Merge branch 'main' of github.com:supermemoryai/supermemory
Diffstat (limited to 'apps/web/app')
| -rw-r--r-- | apps/web/app/(dash)/chat/chatWindow.tsx | 87 |
1 files changed, 49 insertions, 38 deletions
diff --git a/apps/web/app/(dash)/chat/chatWindow.tsx b/apps/web/app/(dash)/chat/chatWindow.tsx index 3d7ca295..662c7217 100644 --- a/apps/web/app/(dash)/chat/chatWindow.tsx +++ b/apps/web/app/(dash)/chat/chatWindow.tsx @@ -23,7 +23,7 @@ import { codeLanguageSubset } from "@/lib/constants"; import { toast } from "sonner"; import Link from "next/link"; import { createChatObject } from "@/app/actions/doers"; -import { ClipboardIcon } from "@heroicons/react/24/outline"; +import { ClipboardIcon, SpeakerWaveIcon } from "@heroicons/react/24/outline"; function ChatWindow({ q, @@ -305,10 +305,25 @@ function ChatWindow({ </Markdown> <div className="mt-3 relative -left-2 flex items-center gap-1"> - {/* TODO: speak response */} - {/* <button className="group h-8 w-8 flex justify-center items-center active:scale-75 duration-200"> - <SpeakerWaveIcon className="size-[18px] group-hover:text-primary" /> - </button> */} + {/* speak response */} + <button + onClick={() => { + const utterThis: SpeechSynthesisUtterance = + new SpeechSynthesisUtterance( + chat.answer.parts + .map((part) => part.text) + .join(""), + ); + const speechSynth: SpeechSynthesis = + window.speechSynthesis; + utterThis.lang = "en-US"; + utterThis.rate = 1; + speechSynth.speak(utterThis); + }} + className="group h-8 w-8 flex justify-center items-center active:scale-75 duration-200" + > + <SpeakerWaveIcon className="size-[18px] group-hover:text-primary" /> + </button> {/* copy response */} <button onClick={() => @@ -388,40 +403,36 @@ function ChatWindow({ ))} </div> - {chat.answer.justification && - chat.answer.justification.length && ( - <div - className={`${chat.answer.justification && chat.answer.justification.length > 0 ? "flex" : "hidden"}`} + {chat.answer.justification?.length && ( + <div + className={`${chat.answer.justification && chat.answer.justification.length > 0 ? "flex" : "hidden"}`} + > + <Accordion + defaultValue={""} + type="single" + collapsible > - <Accordion - defaultValue={""} - type="single" - collapsible - > - <AccordionItem value="justification"> - <AccordionTrigger className="text-foreground-menu"> - Justification - </AccordionTrigger> - <AccordionContent - className="relative flex gap-2 max-w-3xl overflow-auto no-scrollbar" - defaultChecked - > - {chat.answer.justification.length > 0 - ? chat.answer.justification - .replaceAll( - "<justification>", - "", - ) - .replaceAll( - "</justification>", - "", - ) - : "No justification provided."} - </AccordionContent> - </AccordionItem> - </Accordion> - </div> - )} + <AccordionItem value="justification"> + <AccordionTrigger className="text-foreground-menu"> + Justification + </AccordionTrigger> + <AccordionContent + className="relative flex gap-2 max-w-3xl overflow-auto no-scrollbar" + defaultChecked + > + {chat.answer.justification.length > 0 + ? chat.answer.justification + .replaceAll("<justification>", "") + .replaceAll( + "</justification>", + "", + ) + : "No justification provided."} + </AccordionContent> + </AccordionItem> + </Accordion> + </div> + )} </AccordionContent> </AccordionItem> </Accordion> |