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-07 00:32:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ed3a75963cc04c0b72e2435a4dd092323ef5d097
ed3a7596
1 parent
944eecfc
ttp: ready to TTP
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
5 deletions
Voicoding_web/js/ide.js
voicoding.js
Voicoding_web/js/ide.js
View file @
ed3a759
...
...
@@ -1366,7 +1366,7 @@ function transcribeText() {
audioStream
.
getAudioTracks
()[
0
].
stop
();
rec
.
exportWAV
(
uploadSoundData
);
}
let
px
=
0
;
let
input_line
=
""
function
uploadSoundData
(
blob
)
{
let
filename
=
new
Date
().
toISOString
();
...
...
@@ -1374,13 +1374,28 @@ function uploadSoundData(blob) {
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
);
let
transcript
=
JSON
.
parse
(
e
.
target
.
responseText
)
document
.
getElementById
(
"output"
).
innerHTML
+=
`
${
cnt
++
}
:
${
transcript
}
<br><br>`
;
uploadTranscriptData
(
transcript
);
}
};
formData
.
append
(
"audio_data"
,
blob
,
filename
);
xhr
.
open
(
"POST"
,
"/upload_sound"
,
true
);
xhr
.
send
(
formData
);
}
function
uploadTranscriptData
(
txt
)
{
let
request
=
new
XMLHttpRequest
();
let
form
=
new
FormData
();
request
.
onload
=
function
(
e
)
{
if
(
this
.
readyState
===
4
)
{
console
.
log
(
e
.
target
.
responseText
)
input_line
+=
e
.
target
.
responseText
+
'\n'
;
console
.
log
(
input_line
)
sourceEditor
.
setValue
(
input_line
);
}
};
form
.
append
(
"transcript_data"
,
txt
);
request
.
open
(
"POST"
,
"/ttp"
,
true
);
request
.
send
(
form
);
}
\ No newline at end of file
...
...
voicoding.js
View file @
ed3a759
...
...
@@ -62,6 +62,12 @@ app.post('/upload_sound', upload.any(), async (req, res) => {
console
.
log
(
"Text transcription: "
+
transcription
);
res
.
status
(
200
).
send
(
transcription
);
});
app
.
post
(
'/ttp'
,
upload
.
any
(),
async
(
req
,
res
)
=>
{
console
.
log
(
"Getting python code.."
);
let
python_code
=
req
.
body
.
transcript_data
;
console
.
log
(
"Pyton code: "
+
python_code
);
res
.
status
(
200
).
send
(
python_code
);
});
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Express server listening on port:
${
port
}
...`
);
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment