Over the weekend I entered a hackathon with lablab.ai with a focus on ElevenLabs.
"the most advanced text to speech and voice cloning software ever."
I found a bunch of great guys last minute, created a team and built an AI tour guide.
You can view the app here, and uur full application is here. This includes a video with our pitch made by the rest of the team.
To use ElevenLabs in your frontend JavaScript project (speak some text), you can make an API call to them like this
import axios from 'axios';
const playAudio = async ({ text, voiceId }) => {
const response = await axios.post(
`https://api.elevenlabs.io/v1/text-to-speech/${voiceId}`,
{ text },
{
headers: {
'Content-Type': 'application/json',
'xi-api-key': process.env.REACT_APP_ELEVENLABS_API_KEY
},
responseType: 'blob'
}
);
const audio = new Audio(URL.createObjectURL(response.data));
audio.play();
await new Promise(resolve => {
audio.addEventListener('ended', () => {
resolve();
});
});
};
export { playAudio };
-- gist