import { useState } from 'react'; import { textToSpeech } from '../services/api'; import languageVoices from '../data/languageVoices'; // Adjust the path as needed function TextToSpeech() { const [text, setText] = useState(''); const [languageCode, setLanguageCode] = useState('en-US'); const [ssmlGender, setSsmlGender] = useState('NEUTRAL'); const [name, setName] = useState('en-US-Standard-C'); const [pitch, setPitch] = useState(0.0); const [speakingRate, setSpeakingRate] = useState(1.0); const [volumeGainDb, setVolumeGainDb] = useState(0.0); const [audioUrl, setAudioUrl] = useState(null); // Ensure you have VITE_API_URL set in your .env file const API_URL = import.meta.env.VITE_API_URL; const handleTextToSpeech = async () => { // Call text-to-speech service try { const response = await textToSpeech(text, languageCode, ssmlGender, name, pitch, speakingRate, volumeGainDb); const baseUrl = new URL(API_URL); const audioUrl = `${baseUrl.origin}/static/storage/exported/${response}`; console.log(audioUrl) setAudioUrl(audioUrl); } catch (error) { console.error('Text-to-Speech failed:', error); } }; const handleDeleteAudio = () => { setAudioUrl(null); }; return (

Text-to-Speech AI