This commit is contained in:
suraj.shenoy.b@gmail.com
2025-01-25 22:48:10 -06:00
parent 43d710a5a6
commit a7e014f47a
2 changed files with 15 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
//import Hero1 from '@/components/Hero1' //import Hero1 from '@/components/Hero1'
//IMPORT THE HERO1 FUNCTION TO MAKE THE TRANSCRIBE PAGE LOOK BETTER //IMPORT THE HERO1 FUNCTION TO MAKE THE TRANSCRIBE PAGE LOOK BETTER
import React, { useState, useRef } from "react"; import React, { useState, useRef } from "react";
import axios from "axios"; // import axios from "axios";
const AudioTranscriber: React.FC = () => { const AudioTranscriber: React.FC = () => {
const [file, setFile] = useState<File | null>(null); const [file, setFile] = useState<File | null>(null);
@@ -32,24 +32,25 @@ const AudioTranscriber: React.FC = () => {
const formData = new FormData(); const formData = new FormData();
formData.append("file", audioFile); formData.append("file", audioFile);
console.log(audioFile);
setLoading(true); setLoading(true);
setError(null); // Clear previous errors setError(null); // Clear previous errors
try { try {
const response = await axios.post("http://localhost:8000/transcribe", formData, { const response = await fetch("/api/transcribe", {
method: "POST",
body: formData,
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
}, }
}); })
console.log("Transcription response:", response);
console.log("Transcription response:", response.data); // if (response.data && response.data.transcription) {
// setTranscription(response.data.transcription);
if (response.data && response.data.transcription) { // } else {
setTranscription(response.data.transcription); // setError("Unexpected response format. Check backend API.");
} else { // console.error("Invalid response format:", response.data);
setError("Unexpected response format. Check backend API."); // }
console.error("Invalid response format:", response.data);
}
} catch (error) { } catch (error) {
console.error("Error transcribing audio:", error); console.error("Error transcribing audio:", error);
setError("Failed to transcribe audio. Please try again."); setError("Failed to transcribe audio. Please try again.");

View File

@@ -22,6 +22,6 @@
"@/*": ["./src/*"] "@/*": ["./src/*"]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx", "src/app/(web)/transcribe/page.jsx"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }