Spaces:
Runtime error
Runtime error
File size: 1,025 Bytes
3fefa68 a0f1951 3fefa68 c78ca01 3fefa68 a0f1951 3fefa68 a0f1951 3fefa68 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import React, { useState } from 'react';
import axios from 'axios';
const App = () => {
// const [image, setImage] = useState(null);
const [generatedCaption, setGeneratedCaption] = useState('');
const [audioUrl, setAudioUrl] = useState('');
const handleImageUpload = async (event) => {
const file = event.target.files[0];
const formData = new FormData();
formData.append('image', file);
try {
const response = await axios.post('http://5000/upload', formData);
setGeneratedCaption(response.data.generated_caption);
setAudioUrl(response.data.audio_url);
} catch (error) {
console.error('Error uploading image:', error);
}
};
return (
<div className="file-card">
<div className="file-inputs">
<input type="file" onChange={handleImageUpload} accept="image/*" />
{generatedCaption && <p>Generated Caption: {generatedCaption}</p>}
{audioUrl && <audio controls src={audioUrl} />}
</div>
</div>
);
};
export default App;
|