import { useMemo, useState } from "preact/hooks"; import { ChatStore, ChatStoreMessage, addTotalCost } from "./app"; import { Message, getMessageText } from "./chatgpt"; import { SpeakerWaveIcon } from "@heroicons/react/24/outline"; interface TTSProps { chatStore: ChatStore; chat: ChatStoreMessage; setChatStore: (cs: ChatStore) => void; } interface TTSPlayProps { chat: ChatStoreMessage; } export function TTSPlay(props: TTSPlayProps) { const src = useMemo(() => { if (props.chat.audio instanceof Blob) { return URL.createObjectURL(props.chat.audio); } return ""; }, [props.chat.audio]); if (props.chat.hide) { return <>; } if (props.chat.audio instanceof Blob) { return