Blane187 commited on
Commit
2be8bea
1 Parent(s): fb20b43

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +113 -52
index.html CHANGED
@@ -1,62 +1,123 @@
1
- <html>
 
2
  <head>
3
- <title>animalese.js Demo</title>
4
- </head>
5
- <script src="riffwave.js"></script>
6
- <script src="Blob.js"></script>
7
- <script src="FileSaver.min.js"></script>
8
- <script src="animalese.js"></script>
9
- <script>
10
- function dataURItoBlob(dataURI) {
11
- // convert base64/URLEncoded data component to raw binary data held in a string
12
- var byteString;
13
- if (dataURI.split(',')[0].indexOf('base64') >= 0)
14
- byteString = atob(dataURI.split(',')[1]);
15
- else
16
- byteString = unescape(dataURI.split(',')[1]);
17
-
18
- // separate out the mime component
19
- var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- // write the bytes of the string to a typed array
22
- var ia = new Uint8Array(byteString.length);
23
- for (var i = 0; i < byteString.length; i++) {
24
- ia[i] = byteString.charCodeAt(i);
25
- }
26
 
27
- return new Blob([ia], {type:mimeString});
28
- }
29
 
30
- var synth = new Animalese('animalese.wav', function() {
31
- document.getElementById("preview").disabled = false;
32
- document.getElementById("download").disabled = false;
33
- });
34
 
35
- function generateWav() {
36
- return synth.Animalese(document.getElementById("text").value,
37
- document.getElementById("shorten").checked,
38
- document.getElementById("pitch").value).dataURI;
39
- }
40
 
41
- function preview() {
42
- var audio = new Audio();
43
- audio.src = generateWav();
44
- audio.play();
45
- }
46
 
47
- function download() {
48
- var wave = generateWav();
49
- saveAs(dataURItoBlob(wave), "animalese.wav");
50
- }
51
-
52
- </script>
53
  <body>
54
- <h2>animalese.js Demo</h2>
55
- <p>More information and the source at <a href="https://github.com/Acedio/animalese.js">https://github.com/Acedio/animalese.js</a>.</p>
56
- <textarea id="text" rows"4" cols="50">Testing out animalese.js. Did it work?</textarea><br/>
57
- <label>Shorten words<input id="shorten" type="checkbox"/></label><br/>
58
- <label>Grump<input id="pitch" type="range" min="0.2" max="2.0" value="1.0" step="0.1"/>Isabelle</label><br/>
59
- <button id="preview" type="button" disabled="true" onclick="preview()">Preview!</button>
60
- <button id="download" type="button" disabled="false" onclick="download()">Download!</button>
 
 
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>