Skip to content

Commit

Permalink
Merge pull request #4 from Jane232/main
Browse files Browse the repository at this point in the history
Fix issue #3 - Add error messages
  • Loading branch information
TheMorpheus407 authored Dec 13, 2023
2 parents a357f7d + 76c6505 commit bd8d138
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ <h1>Text-to-Audio Converter</h1>
<div id="generate-section">
<button id="generate-audiobook">Generate Audiobook</button>
</div>

<!-- Error Indicator (Hidden Initially) -->
<div id="error-indicator" style="display: none;">
<p style="color:red;">An error occured calling the OpenAI API: <br/>Are you sure that the entered key is valid and that there is enough credit balance on your account?</p>
</div>
<!-- Progress Indicator (Hidden Initially) -->
<div id="progress-indicator" style="display: none;">
<p>Converting...</p>
Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function generateAudiobook() {
var segments = splitTextIntoSegments(text, 4000);
var audioBlobs = new Array(segments.length);
var progressBar = document.getElementById('progressbar1');
document.getElementById('error-indicator').style.display = 'none';
progressBar.max = segments.length;
progressBar.value = 0;

Expand Down Expand Up @@ -150,6 +151,7 @@ function callOpenAIAPI(segment, apiKey, callback) {
callback(audioBlob);
} else {
console.error("Error calling OpenAI API: " + xhr.statusText);
document.getElementById('error-indicator').style.display = 'block';
}
};

Expand Down

0 comments on commit bd8d138

Please sign in to comment.