Spaces:
Running
Running
File size: 1,125 Bytes
654b645 |
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 37 38 39 40 41 |
var app = {
init: function() {
// Get the elements we need
var textInput = $("#text-input");
var synthesizeButton = $("#synthesize-button");
var closeButton = $("#close-button");
// Add click events to the buttons
synthesizeButton.on('click', function() {
// Get the text to synthesize
var text = textInput.val();
// Make a request to the FastAPI server
$.ajax({
url: '/synthesize',
method: 'POST',
data: {
text: text
},
success: function(response) {
// Play the synthesized audio
var audio = new Audio(response.audio_url);
audio.play();
},
error: function(error) {
console.log(error);
}
});
});
closeButton.on('click', function() {
// Close the window
window.close();
});
}
};
$(document).ready(function() {
app.init();
});
|