Spaces:
Runtime error
Runtime error
| 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(); | |
| }); | |