Spaces:
Running
Running
Update index.html
Browse files- index.html +113 -52
index.html
CHANGED
|
@@ -1,62 +1,123 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
<head>
|
| 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 |
-
var synth = new Animalese('animalese.wav', function() {
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
});
|
| 34 |
|
| 35 |
-
function generateWav() {
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
}
|
| 40 |
|
| 41 |
-
function preview() {
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
}
|
| 46 |
|
| 47 |
-
function download() {
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
</
|
| 53 |
<body>
|
| 54 |
-
<
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
</body>
|
| 62 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Animalese.js Demo</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
font-family: 'Roboto', sans-serif;
|
| 11 |
+
background-color: #f5f5f5;
|
| 12 |
+
color: #333;
|
| 13 |
+
display: flex;
|
| 14 |
+
flex-direction: column;
|
| 15 |
+
align-items: center;
|
| 16 |
+
margin: 0;
|
| 17 |
+
padding: 20px;
|
| 18 |
+
}
|
| 19 |
+
h2 {
|
| 20 |
+
color: #4CAF50;
|
| 21 |
+
}
|
| 22 |
+
.container {
|
| 23 |
+
background-color: #fff;
|
| 24 |
+
padding: 20px;
|
| 25 |
+
border-radius: 8px;
|
| 26 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 27 |
+
max-width: 600px;
|
| 28 |
+
width: 100%;
|
| 29 |
+
}
|
| 30 |
+
textarea {
|
| 31 |
+
width: 100%;
|
| 32 |
+
padding: 10px;
|
| 33 |
+
border: 1px solid #ccc;
|
| 34 |
+
border-radius: 4px;
|
| 35 |
+
resize: vertical;
|
| 36 |
+
margin-bottom: 10px;
|
| 37 |
+
}
|
| 38 |
+
label {
|
| 39 |
+
display: flex;
|
| 40 |
+
align-items: center;
|
| 41 |
+
margin-bottom: 10px;
|
| 42 |
+
}
|
| 43 |
+
input[type="checkbox"],
|
| 44 |
+
input[type="range"] {
|
| 45 |
+
margin-left: 10px;
|
| 46 |
+
}
|
| 47 |
+
button {
|
| 48 |
+
background-color: #4CAF50;
|
| 49 |
+
color: white;
|
| 50 |
+
border: none;
|
| 51 |
+
padding: 10px 20px;
|
| 52 |
+
border-radius: 4px;
|
| 53 |
+
cursor: pointer;
|
| 54 |
+
margin-right: 10px;
|
| 55 |
+
}
|
| 56 |
+
button:disabled {
|
| 57 |
+
background-color: #ddd;
|
| 58 |
+
cursor: not-allowed;
|
| 59 |
+
}
|
| 60 |
+
a {
|
| 61 |
+
color: #4CAF50;
|
| 62 |
+
text-decoration: none;
|
| 63 |
+
}
|
| 64 |
+
a:hover {
|
| 65 |
+
text-decoration: underline;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
+
<script src="riffwave.js"></script>
|
| 69 |
+
<script src="Blob.js"></script>
|
| 70 |
+
<script src="FileSaver.min.js"></script>
|
| 71 |
+
<script src="animalese.js"></script>
|
| 72 |
+
<script>
|
| 73 |
+
function dataURItoBlob(dataURI) {
|
| 74 |
+
var byteString;
|
| 75 |
+
if (dataURI.split(',')[0].indexOf('base64') >= 0)
|
| 76 |
+
byteString = atob(dataURI.split(',')[1]);
|
| 77 |
+
else
|
| 78 |
+
byteString = unescape(dataURI.split(',')[1]);
|
| 79 |
|
| 80 |
+
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
| 81 |
+
var ia = new Uint8Array(byteString.length);
|
| 82 |
+
for (var i = 0; i < byteString.length; i++) {
|
| 83 |
+
ia[i] = byteString.charCodeAt(i);
|
| 84 |
+
}
|
| 85 |
|
| 86 |
+
return new Blob([ia], { type: mimeString });
|
| 87 |
+
}
|
| 88 |
|
| 89 |
+
var synth = new Animalese('animalese.wav', function () {
|
| 90 |
+
document.getElementById("preview").disabled = false;
|
| 91 |
+
document.getElementById("download").disabled = false;
|
| 92 |
+
});
|
| 93 |
|
| 94 |
+
function generateWav() {
|
| 95 |
+
return synth.Animalese(document.getElementById("text").value,
|
| 96 |
+
document.getElementById("shorten").checked,
|
| 97 |
+
document.getElementById("pitch").value).dataURI;
|
| 98 |
+
}
|
| 99 |
|
| 100 |
+
function preview() {
|
| 101 |
+
var audio = new Audio();
|
| 102 |
+
audio.src = generateWav();
|
| 103 |
+
audio.play();
|
| 104 |
+
}
|
| 105 |
|
| 106 |
+
function download() {
|
| 107 |
+
var wave = generateWav();
|
| 108 |
+
saveAs(dataURItoBlob(wave), "animalese.wav");
|
| 109 |
+
}
|
| 110 |
+
</script>
|
| 111 |
+
</head>
|
| 112 |
<body>
|
| 113 |
+
<div class="container">
|
| 114 |
+
<h2>Animalese.js Demo</h2>
|
| 115 |
+
<p>More information and the source at <a href="https://github.com/Acedio/animalese.js">https://github.com/Acedio/animalese.js</a>.</p>
|
| 116 |
+
<textarea id="text" rows="4" cols="50">Testing out animalese.js. Did it work?</textarea><br/>
|
| 117 |
+
<label>Shorten words<input id="shorten" type="checkbox" /></label><br/>
|
| 118 |
+
<label>Grump<input id="pitch" type="range" min="0.2" max="2.0" value="1.0" step="0.1" />Isabelle</label><br/>
|
| 119 |
+
<button id="preview" type="button" disabled="true" onclick="preview()">Preview!</button>
|
| 120 |
+
<button id="download" type="button" disabled="true" onclick="download()">Download!</button>
|
| 121 |
+
</div>
|
| 122 |
</body>
|
| 123 |
</html>
|