천현우

ttp: input line connect to judge0

......@@ -13,7 +13,6 @@
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@200&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+KR&family=Raleway:wght@200&display=swap" rel="stylesheet">
<script defer src="https://cdn.rawgit.com/mattdiamond/Recorderjs/08e7abd9/dist/recorder.js"></script>
<script defer src="client.js"></script>
<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.">
<meta name="keywords" content="online editor, online code editor, online ide, online compiler, online interpreter, run code online, learn programming online,
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() {
audioStream.getAudioTracks()[0].stop();
rec.exportWAV(uploadSoundData);
}
let px = 0;
let input_line = ""
function uploadSoundData(blob) {
let filename = new Date().toISOString();
let xhr = new XMLHttpRequest();
let formData = new FormData();
xhr.onload = function(e) {
if(this.readyState === 4) {
document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br><br>`;
input_line += 'print("hello")';
sourceEditor.setValue(input_line);
}
};
formData.append("audio_data", blob, filename);
......
......@@ -400,7 +400,7 @@ function changeEditorLanguage() {
function insertTemplate() {
currentLanguageId = parseInt(71);
sourceEditor.setValue(sources[currentLanguageId]);
//sourceEditor.setValue(sources[currentLanguageId]+'\n'+'print("hello world")');
changeEditorLanguage();
}
......@@ -1336,3 +1336,51 @@ var languageApiUrlTable = {
1023: extraApiUrl,
1024: extraApiUrl
}
let rec = null;
let audioStream = null;
const recordButton = document.getElementById("recordButton");
const transcribeButton = document.getElementById("transcribeButton");
recordButton.addEventListener("click", startRecording);
transcribeButton.addEventListener("click", transcribeText);
let cnt = 1;
function startRecording() {
let constraints = { audio: true, video:false }
recordButton.disabled = true;
transcribeButton.disabled = false;
navigator.mediaDevices.getUserMedia(constraints).then(function(stream) {
const audioContext = new window.AudioContext();
audioStream = stream;
const input = audioContext.createMediaStreamSource(stream);
rec = new Recorder(input, { numChannels:1 })
rec.record()
}).catch(function(err) {
recordButton.disabled = false;
transcribeButton.disabled = true;
});
}
function transcribeText() {
transcribeButton.disabled = true;
recordButton.disabled = false;
rec.stop();
audioStream.getAudioTracks()[0].stop();
rec.exportWAV(uploadSoundData);
}
let px = 0;
let input_line = ""
function uploadSoundData(blob) {
let filename = new Date().toISOString();
let xhr = new XMLHttpRequest();
let formData = new FormData();
xhr.onload = function(e) {
if(this.readyState === 4) {
document.getElementById("output").innerHTML += `${cnt++}: ${JSON.parse(e.target.responseText)}<br><br>`;
input_line += 'print("hello")\n';
sourceEditor.setValue(input_line);
}
};
formData.append("audio_data", blob, filename);
xhr.open("POST", "/upload_sound", true);
xhr.send(formData);
}
\ No newline at end of file
......