Toggle navigation
Toggle navigation
This project
Loading...
Sign in
천현우
/
Voicoding
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
천현우
2021-06-06 21:31:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f8501aade4d78f60322ecc79d16ebbc8e6c49ae8
f8501aad
1 parent
fea1962b
ttp: input line connect to judge0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
5 deletions
Voicoding_web/Voico_Home.html
Voicoding_web/client.js
Voicoding_web/js/ide.js
Voicoding_web/js/package-lock.json
Voicoding_web/Voico_Home.html
View file @
f8501aa
...
...
@@ -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,
...
...
Voicoding_web/client.js
View file @
f8501aa
...
...
@@ -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
);
...
...
Voicoding_web/js/ide.js
View file @
f8501aa
...
...
@@ -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
...
...
Voicoding_web/js/package-lock.json
deleted
100644 → 0
View file @
fea1962
{
"lockfileVersion"
:
1
}
Please
register
or
login
to post a comment