import { Meta, StoryObj } from "@storybook/react-vite"; import TextToSpeech from "./TextToSpeech"; import "./text-to-speech.scss"; const meta: Meta = { title: "FP.React Components/TextToSpeech", component: TextToSpeech, tags: ["experimental"], argTypes: { voice: { control: { type: "select", options: [ "Google US English", "Google UK English Female", "Google UK English Male", ], }, }, }, } as Story; export default meta; type Story = StoryObj; export const Default: Story = { args: { label: "Read post", initialText: "Hello, how are you? I am a Text to Speech (TTS) assistant! Update this text and click the [speak] button to hear the change.", }, parameters: { docs: { description: { story: "This story demonstrates the TextToSpeechComponent with predefined text and hidden text input. It's useful for scenarios where you want to display the component with a fixed text, without allowing the user to modify it.", }, }, }, } as Story; export const WithText: Story = { args: { // Add props to simulate text input initialText: "This is a test of the text to speech component. Here the test is passed as a prop and the text input is hidden.", showTextInput: false, }, parameters: { docs: { description: { story: "This story demonstrates the TextToSpeechComponent with predefined text and hidden text input. It's useful for scenarios where you want to display the component with a fixed text, without allowing the user to modify it.", }, }, }, } as Story; // export const FullFeature: Story = { // args: { // initialText: // "Welcome to the full-featured Text-to-Speech component. You can modify this text, choose a voice, adjust pitch and rate, and then click the speak button to hear it.", // showTextInput: true, // pitch: 1, // rate: 1, // }, // parameters: { // docs: { // description: { // story: // "This story showcases all features of the TextToSpeechComponent, including text input, voice selection, pitch and rate adjustment. It provides a comprehensive demonstration of the component's capabilities.", // }, // }, // }, // render: (args) => { // const [selectedVoice, setSelectedVoice] = React.useState< // SpeechSynthesisVoice | undefined // >(undefined); // const [pitch, setPitch] = React.useState(1); // const [rate, setRate] = React.useState(1); // React.useEffect(() => { // const voices = window.speechSynthesis.getVoices(); // setSelectedVoice( // voices.find((voice) => voice.name === "Google US English") || voices[0] // ); // }, []); // return ( //
// //
// // //
//
// // setPitch(parseFloat(e.target.value))} // /> //
//
// // setRate(parseFloat(e.target.value))} // /> //
//
// ); // }, // } as Story;