Phonetic Transcription Generator
Convert text into its phonetic representation using AI.
Generated Transcription:
${originalText}
Transcription (${alphabetSelect.value})
${transcriptionText}
`;
pdfContentArea.style.display = 'block';
pdfContentArea.style.position = 'absolute';
pdfContentArea.style.left = '-9999px';
pdfContentArea.style.width = '800px';
try {
const canvas = await html2canvas(pdfContentArea, { scale: 2 });
const imgData = canvas.toDataURL('image/png');
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const imgHeight = canvas.height * pdfWidth / canvas.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, imgHeight);
pdf.save(`Phonetic-Transcription-Report.pdf`);
} catch (error) {
console.error("Failed to generate PDF:", error);
alert("Sorry, there was an error creating the PDF file.");
} finally {
pdfContentArea.style.display = 'none';
}
}
// --- Event Listeners ---
generateBtn.addEventListener('click', getTranscription);
downloadPdfBtn.addEventListener('click', generatePdf);
// --- Initial State ---
textInput.value = "Hello, how are you doing today?";
});
