Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions mlx_audio/tts/audio_player.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ <h1>MLX-Audio Player</h1>
const glowMesh = new THREE.Mesh(glowGeometry, glowMaterial);
scene.add(glowMesh);

// Define rotation speed variables
let rotationSpeedY = 0.002;
let rotationSpeedX = 0.001;
let isGenerating = false;

// Tab functionality
function openTab(evt, tabName) {
// Hide all tabcontent
Expand Down Expand Up @@ -355,6 +360,11 @@ <h1>MLX-Audio Player</h1>
ttsErrorElement.style.display = 'none';
ttsStatusElement.textContent = 'Generating speech...';

// Increase rotation speed to indicate processing
isGenerating = true;
rotationSpeedY = 0.01;
rotationSpeedX = 0.005;

// Create form data
const formData = new FormData();
formData.append('text', text);
Expand All @@ -378,6 +388,11 @@ <h1>MLX-Audio Player</h1>
.then(data => {
ttsStatusElement.textContent = 'Speech generated successfully!';

// Reset rotation speed
isGenerating = false;
rotationSpeedY = 0.002;
rotationSpeedX = 0.001;

// Clean up previous audio resources
if (audioElement) {
audioElement.pause();
Expand Down Expand Up @@ -414,7 +429,11 @@ <h1>MLX-Audio Player</h1>
})
.catch(error => {
showTtsError(error.message);
ttsStatusElement.textContent = '';

// Reset rotation speed on error too
isGenerating = false;
rotationSpeedY = 0.002;
rotationSpeedX = 0.001;
});
});

Expand Down Expand Up @@ -576,9 +595,9 @@ <h1>MLX-Audio Player</h1>
// Get current time for pulsating effect
const time = performance.now() * 0.001; // Convert to seconds

// Rotate sphere slowly
sphere.rotation.y += 0.002;
sphere.rotation.x += 0.001;
// Rotate sphere with current speed
sphere.rotation.y += rotationSpeedY;
sphere.rotation.x += rotationSpeedX;
glowMesh.rotation.copy(sphere.rotation);

// Update visualization if audio is playing
Expand Down