Spaces:
Sleeping
Sleeping
Commit
·
13a4f5e
1
Parent(s):
4b5f136
fixing tmp file error
Browse files- app/tmp/html.txt +104 -0
app/tmp/html.txt
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>Mood-Based Music Recommendation</title>
|
| 5 |
+
<style>
|
| 6 |
+
/* Your existing CSS styles here */
|
| 7 |
+
body {
|
| 8 |
+
font-family: Arial, sans-serif;
|
| 9 |
+
background-color: #f2f2f2;
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
.container {
|
| 15 |
+
display: flex;
|
| 16 |
+
justify-content: center;
|
| 17 |
+
align-items: center;
|
| 18 |
+
height: 100vh;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
.prompt {
|
| 22 |
+
background-color: #fff;
|
| 23 |
+
padding: 20px;
|
| 24 |
+
border-radius: 10px;
|
| 25 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 26 |
+
text-align: center;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
button {
|
| 30 |
+
background-color: #4CAF50;
|
| 31 |
+
color: white;
|
| 32 |
+
padding: 10px 20px;
|
| 33 |
+
border: none;
|
| 34 |
+
border-radius: 4px;
|
| 35 |
+
cursor: pointer;
|
| 36 |
+
margin: 10px;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
button:hover {
|
| 40 |
+
background-color: #45a049;
|
| 41 |
+
}
|
| 42 |
+
</style>
|
| 43 |
+
</head>
|
| 44 |
+
<body>
|
| 45 |
+
<div class="container">
|
| 46 |
+
<div class="prompt">
|
| 47 |
+
<!-- Audio prompt -->
|
| 48 |
+
<audio controls autoplay id="audioPrompt">
|
| 49 |
+
<source src="how_are_you_feeling_today.mp3" type="audio/mpeg">
|
| 50 |
+
Your browser does not support the audio element.
|
| 51 |
+
</audio>
|
| 52 |
+
<button id="startBtn" onclick="startRecording()">Start Recording</button>
|
| 53 |
+
<button id="stopBtn" onclick="stopRecording()" disabled>Stop Recording</button>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
<script>
|
| 57 |
+
let mediaRecorder;
|
| 58 |
+
let recordedChunks = [];
|
| 59 |
+
|
| 60 |
+
function startRecording() {
|
| 61 |
+
navigator.mediaDevices.getUserMedia({ audio: true })
|
| 62 |
+
.then(function (stream) {
|
| 63 |
+
mediaRecorder = new MediaRecorder(stream);
|
| 64 |
+
mediaRecorder.ondataavailable = function (event) {
|
| 65 |
+
recordedChunks.push(event.data);
|
| 66 |
+
};
|
| 67 |
+
mediaRecorder.onstop = function () {
|
| 68 |
+
const audioBlob = new Blob(recordedChunks, { type: 'audio/mp3' });
|
| 69 |
+
|
| 70 |
+
// Create a download link to save the audio recording
|
| 71 |
+
const downloadLink = document.createElement('a');
|
| 72 |
+
downloadLink.href = URL.createObjectURL(audioBlob);
|
| 73 |
+
downloadLink.download = 'recorded_audio.mp3';
|
| 74 |
+
downloadLink.click();
|
| 75 |
+
|
| 76 |
+
// Reset the recordedChunks for the next recording
|
| 77 |
+
recordedChunks = [];
|
| 78 |
+
};
|
| 79 |
+
mediaRecorder.start();
|
| 80 |
+
document.getElementById("startBtn").disabled = true;
|
| 81 |
+
document.getElementById("stopBtn").disabled = false;
|
| 82 |
+
|
| 83 |
+
// Pause the audio prompt while recording
|
| 84 |
+
const audioPrompt = document.getElementById("audioPrompt");
|
| 85 |
+
audioPrompt.pause();
|
| 86 |
+
})
|
| 87 |
+
.catch(function (err) {
|
| 88 |
+
console.log("Error accessing microphone:", err);
|
| 89 |
+
});
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
function stopRecording() {
|
| 93 |
+
mediaRecorder.stop();
|
| 94 |
+
document.getElementById("startBtn").disabled = false;
|
| 95 |
+
document.getElementById("stopBtn").disabled = true;
|
| 96 |
+
|
| 97 |
+
// Resume the audio prompt after recording
|
| 98 |
+
const audioPrompt = document.getElementById("audioPrompt");
|
| 99 |
+
audioPrompt.play();
|
| 100 |
+
}
|
| 101 |
+
</script>
|
| 102 |
+
</body>
|
| 103 |
+
</html>
|
| 104 |
+
|