천현우

ttp: input line connect to judge0

...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
13 <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200&display=swap" rel="stylesheet"> 13 <link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200&display=swap" rel="stylesheet">
14 <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR&family=Raleway:wght@200&display=swap" rel="stylesheet"> 14 <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR&family=Raleway:wght@200&display=swap" rel="stylesheet">
15 <script defer src="https://cdn.rawgit.com/mattdiamond/Recorderjs/08e7abd9/dist/recorder.js"></script> 15 <script defer src="https://cdn.rawgit.com/mattdiamond/Recorderjs/08e7abd9/dist/recorder.js"></script>
16 - <script defer src="client.js"></script>
17 <meta name="description" content="Free and open-source online code editor that allows you to write and execute code from a rich set of languages."> 16 <meta name="description" content="Free and open-source online code editor that allows you to write and execute code from a rich set of languages.">
18 <meta name="keywords" content="online editor, online code editor, online ide, online compiler, online interpreter, run code online, learn programming online, 17 <meta name="keywords" content="online editor, online code editor, online ide, online compiler, online interpreter, run code online, learn programming online,
19 online debugger, programming in browser, online code runner, online code execution, debug online, debug C code online, debug C++ code online, 18 online debugger, programming in browser, online code runner, online code execution, debug online, debug C code online, debug C++ code online,
......
...@@ -27,13 +27,18 @@ function transcribeText() { ...@@ -27,13 +27,18 @@ function transcribeText() {
27 audioStream.getAudioTracks()[0].stop(); 27 audioStream.getAudioTracks()[0].stop();
28 rec.exportWAV(uploadSoundData); 28 rec.exportWAV(uploadSoundData);
29 } 29 }
30 +let px = 0;
31 +let input_line = ""
30 function uploadSoundData(blob) { 32 function uploadSoundData(blob) {
31 let filename = new Date().toISOString(); 33 let filename = new Date().toISOString();
32 let xhr = new XMLHttpRequest(); 34 let xhr = new XMLHttpRequest();
33 let formData = new FormData(); 35 let formData = new FormData();
34 xhr.onload = function(e) { 36 xhr.onload = function(e) {
35 if(this.readyState === 4) { 37 if(this.readyState === 4) {
38 +
36 document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br><br>`; 39 document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br><br>`;
40 + input_line += 'print("hello")';
41 + sourceEditor.setValue(input_line);
37 } 42 }
38 }; 43 };
39 formData.append("audio_data", blob, filename); 44 formData.append("audio_data", blob, filename);
......
...@@ -400,7 +400,7 @@ function changeEditorLanguage() { ...@@ -400,7 +400,7 @@ function changeEditorLanguage() {
400 400
401 function insertTemplate() { 401 function insertTemplate() {
402 currentLanguageId = parseInt(71); 402 currentLanguageId = parseInt(71);
403 - sourceEditor.setValue(sources[currentLanguageId]); 403 + //sourceEditor.setValue(sources[currentLanguageId]+'\n'+'print("hello world")');
404 changeEditorLanguage(); 404 changeEditorLanguage();
405 } 405 }
406 406
...@@ -1336,3 +1336,51 @@ var languageApiUrlTable = { ...@@ -1336,3 +1336,51 @@ var languageApiUrlTable = {
1336 1023: extraApiUrl, 1336 1023: extraApiUrl,
1337 1024: extraApiUrl 1337 1024: extraApiUrl
1338 } 1338 }
1339 +
1340 +let rec = null;
1341 +let audioStream = null;
1342 +const recordButton = document.getElementById("recordButton");
1343 +const transcribeButton = document.getElementById("transcribeButton");
1344 +recordButton.addEventListener("click", startRecording);
1345 +transcribeButton.addEventListener("click", transcribeText);
1346 +let cnt = 1;
1347 +function startRecording() {
1348 + let constraints = { audio: true, video:false }
1349 + recordButton.disabled = true;
1350 + transcribeButton.disabled = false;
1351 + navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
1352 + const audioContext = new window.AudioContext();
1353 + audioStream = stream;
1354 + const input = audioContext.createMediaStreamSource(stream);
1355 + rec = new Recorder(input, { numChannels:1 })
1356 + rec.record()
1357 + }).catch(function(err) {
1358 + recordButton.disabled = false;
1359 + transcribeButton.disabled = true;
1360 + });
1361 +}
1362 +function transcribeText() {
1363 + transcribeButton.disabled = true;
1364 + recordButton.disabled = false;
1365 + rec.stop();
1366 + audioStream.getAudioTracks()[0].stop();
1367 + rec.exportWAV(uploadSoundData);
1368 +}
1369 +let px = 0;
1370 +let input_line = ""
1371 +function uploadSoundData(blob) {
1372 + let filename = new Date().toISOString();
1373 + let xhr = new XMLHttpRequest();
1374 + let formData = new FormData();
1375 + xhr.onload = function(e) {
1376 + if(this.readyState === 4) {
1377 +
1378 + document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br><br>`;
1379 + input_line += 'print("hello")\n';
1380 + sourceEditor.setValue(input_line);
1381 + }
1382 + };
1383 + formData.append("audio_data", blob, filename);
1384 + xhr.open("POST", "/upload_sound", true);
1385 + xhr.send(formData);
1386 +}
...\ No newline at end of file ...\ No newline at end of file
......
1 -{
2 - "lockfileVersion": 1
3 -}