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 20:44:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8452b8977e3ab5a1f2c38fa2348ba319b8bfce87
8452b897
1 parent
ed3a7596
TTP: update functions for ttp
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
223 additions
and
9 deletions
Manual.txt
Voicoding_web/js/ide.js
voicoding.js
Manual.txt
View file @
8452b89
1.
2.
3.
\ No newline at end of file
'기본 함수 사용',
'인풋', -> input()
'스플릿', -> .split()
'프린트', -> print(
'섬', -> sum(
'맥스', -> max(
'민' -> min(
'렌' -> len(
'수식' -> +, -, *, /, 몫, 나머지
=> 뒤에 나오는걸 parameter로 넣어야 함
'변수 선언' -> 문자, 숫자, 리스트, 함수
는 -> =
첫번째 - -> =
리스트 -> c는 빈 리스트-> c = []
c는 숫자 리스트 1 2 3 4 5 6 -> c = [1, 2, 3, 4, 5, 6]
c는 문자 리스트 a b c d -> c = ['a', 'b', 'c', 'd']
'반복문 선언'
for a in range -> for a in range(
for i in (li):
while -> while(
'조건문 선언'
if -> if(
else if -> elif(
else -> else:
'함수 선언'
aaa -> def aaa(
'완료' -> tab 빼기
'파라미터 선언'
a b c -> a, b, c):
'논리 식 선언'
1: A는 B 와 같다 -> A == B):
2: A는 B 보다 크다 -> A > B):
5: A는 B 보다 크거나 같다 -> A >= B):
6: A는 B 보다 작거나 같다 -> A <= B):
7: A는 B 보다 작다 -> A < B):
...
...
Voicoding_web/js/ide.js
View file @
8452b89
...
...
@@ -1390,8 +1390,7 @@ function uploadTranscriptData(txt) {
request
.
onload
=
function
(
e
)
{
if
(
this
.
readyState
===
4
)
{
console
.
log
(
e
.
target
.
responseText
)
input_line
+=
e
.
target
.
responseText
+
'\n'
;
console
.
log
(
input_line
)
input_line
+=
e
.
target
.
responseText
;
sourceEditor
.
setValue
(
input_line
);
}
};
...
...
voicoding.js
View file @
8452b89
...
...
@@ -20,7 +20,14 @@ async function testGoogleTextToSpeech(audioBuffer) {
'$$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE'
,
'$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE 보다 크다'
,
'$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE 보다 작다'
,
'for OOV_CLASS_ALPHA_SEQUENCE in range $OOV_CLASS_ALPHANUMERIC_SEQUENCE'
,
'$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE 와 같다'
,
'$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE 보다 작거나 같다'
,
'$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 $OOV_CLASS_ALPHANUMERIC_SEQUENCE 보다 크거나 같다'
,
'for $OOV_CLASS_ALPHA_SEQUENCE in'
,
'for $OOV_CLASS_ALPHA_SEQUENCE in'
,
'$$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 빈 리스트'
,
'$$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 숫자 리스트 $OOV_CLASS_ALPHANUMERIC_SEQUENCE'
,
'$$OOV_CLASS_ALPHANUMERIC_SEQUENCE 는 문자 리스트 $OOV_CLASS_ALPHANUMERIC_SEQUENCE'
,
'if'
,
'이프'
,
'else if'
,
...
...
@@ -30,12 +37,22 @@ async function testGoogleTextToSpeech(audioBuffer) {
'while'
,
'와일'
,
'함수'
,
'파라미터'
,
'파라미터
선언
'
,
'parameter'
,
'변수 선언'
,
'함수 선언'
,
'반복문 선언'
,
'조건문 선언'
'조건문 선언'
,
'기본 함수 사용'
,
'인풋'
,
'스플릿'
,
'프린트'
,
'섬'
,
'맥스'
,
'민'
,
'렌'
,
'리턴'
,
'리스트'
],
boost
:
20
}]
...
...
@@ -56,6 +73,164 @@ async function testGoogleTextToSpeech(audioBuffer) {
.
map
(
result
=>
result
.
alternatives
[
0
].
transcript
);
return
transcription
;
}
let
before_val
=
''
;
let
tab
=
''
;
let
ent
=
''
;
async
function
TextToPython
(
trans_data
)
{
let
text_list
=
trans_data
.
split
(
' '
);
console
.
log
(
text_list
);
switch
(
text_list
[
0
]){
case
'기본'
:
before_val
=
text_list
[
0
];
switch
(
text_list
[
3
]){
case
'프린트'
:
return
tab
+
'print('
;
case
'인풋'
:
return
tab
+
'input()'
;
case
'스플릿'
:
return
'.split()'
;
case
'섬'
:
return
'sum('
;
case
'맥스'
:
return
'max('
;
case
'민'
:
return
'min('
;
case
'렌'
:
return
'len('
;
}
break
;
case
'파라미터'
:
if
(
text_list
.
length
<
3
)
return
''
;
if
(
before_val
==
'기본'
){
before_val
=
'파라미터'
;
return
text_list
.
slice
(
2
).
join
()
+
')\n'
;
}
else
{
before_val
=
'파라미터'
;
tab
+=
'\t'
;
return
text_list
.
slice
(
2
).
join
()
+
'):\n'
;
}
break
;
case
'변수'
:
if
(
before_val
==
'기본'
){
ent
=
'\n'
;
}
else
{
ent
=
''
;
}
before_val
=
'변수'
;
if
(
text_list
.
length
<
4
)
return
''
;
if
(
text_list
[
2
]
==
'문자'
){
if
(
text_list
[
3
][
text_list
[
3
].
length
-
1
]
==
'는'
){
return
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = "'
+
text_list
.
slice
(
4
).
join
(
' '
)
+
'"\n'
;
}
else
{
text_list
[
4
]
=
'= "'
;
return
ent
+
tab
+
text_list
.
slice
(
3
).
join
(
' '
)
+
'"\n'
;
}
}
else
if
(
text_list
[
2
]
==
'숫자'
){
if
(
text_list
[
3
][
text_list
[
3
].
length
-
1
]
==
'는'
){
return
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = '
+
text_list
.
slice
(
4
).
join
(
' '
)
+
'\n'
;
}
else
if
(
text_list
[
4
]
==
'-'
){
text_list
[
4
]
=
'='
;
return
ent
+
tab
+
text_list
.
slice
(
3
).
join
(
' '
)
+
'\n'
;
}
}
else
if
(
text_list
[
2
]
==
'함수'
){
if
(
text_list
[
3
][
text_list
[
3
].
length
-
1
]
==
'는'
){
return
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = '
;
}
else
{
text_list
[
4
]
=
'='
;
return
ent
+
tab
+
text_list
.
slice
(
3
)
}
}
else
if
(
text_list
[
2
]
==
'리스트'
){
if
(
text_list
[
3
][
text_list
[
3
].
length
-
1
]
==
'는'
){
if
(
text_list
[
4
]
==
'빈'
)
return
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = []\n'
;
else
if
(
text_list
[
4
]
==
'숫자'
)
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = ['
+
text_list
.
slice
(
6
).
join
(
','
)
+
']\n'
;
else
return
ent
+
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' = ["'
+
text_list
.
slice
(
6
).
join
(
'","'
)
+
'"]\n'
;
}
}
else
return
''
;
break
;
case
'반복문'
:
if
(
before_val
==
'기본'
){
ent
=
'\n'
;
}
else
{
ent
=
''
;
}
if
(
text_list
[
3
]
==
'for'
){
return
ent
+
tab
+
text_list
.
slice
(
3
).
join
(
' '
)
+
' ('
}
else
if
(
text_list
[
3
]
==
'while'
||
text_list
[
3
]
==
'와일'
){
return
ent
+
tab
+
'while ('
;
}
else
return
''
;
break
;
case
'완료'
:
tab
.
slice
(
1
);
return
''
;
break
;
case
'함수'
:
if
(
before_val
==
'기본'
){
ent
=
'\n'
;
}
else
{
ent
=
''
;
}
if
(
text_list
.
length
>=
3
)
return
'def '
+
text_list
.
slice
(
2
).
join
(
''
)
+
'('
;
else
return
''
;
case
'조건문'
:
if
(
before_val
==
'기본'
){
ent
=
'\n'
;
}
else
{
ent
=
''
;
}
if
(
text_list
.
length
>=
3
){
if
(
text_list
[
3
]
==
'if'
||
text_list
[
3
]
==
'이프'
){
return
tab
+
'if ('
;
}
else
if
((
text_list
[
3
]
==
'else'
||
text_list
[
3
]
==
'엘스'
)){
tab
+=
1
;
return
'\t'
*
(
tab
-
1
)
+
'else:\n'
}
else
if
((
text_list
[
3
]
==
'else'
||
text_list
[
3
]
==
'엘스'
)
&&
(
text_list
[
4
]
==
'if'
||
text_list
[
4
]
==
'이프'
)){
return
tab
+
'elif ('
;
}
}
else
return
''
;
break
;
case
'논리'
:
if
(
text_list
.
length
>=
7
){
tab
+=
1
;
if
(
text_list
[
6
]
==
'같다'
){
return
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' == '
+
text_list
[
4
]
+
'):\n'
;
}
else
if
(
text_list
[
6
]
==
'크다'
){
return
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' > '
+
text_list
[
4
]
+
'):\n'
;
}
else
if
(
text_list
[
6
]
==
'작다'
){
return
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' < '
+
text_list
[
4
]
+
'):\n'
;
}
else
if
(
text_list
[
6
]
==
'크거나'
){
return
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' >= '
+
text_list
[
4
]
+
'):\n'
;
}
else
if
(
text_list
[
6
]
==
'작거나'
){
return
tab
+
text_list
[
3
].
slice
(
0
,
text_list
[
3
].
length
-
1
)
+
' <= '
+
text_list
[
4
]
+
'):\n'
;
}
}
else
return
''
;
break
;
default
:
return
''
}
}
app
.
post
(
'/upload_sound'
,
upload
.
any
(),
async
(
req
,
res
)
=>
{
console
.
log
(
"Getting text transcription.."
);
let
transcription
=
await
testGoogleTextToSpeech
(
req
.
files
[
0
].
buffer
);
...
...
@@ -64,7 +239,7 @@ app.post('/upload_sound', upload.any(), async (req, res) => {
});
app
.
post
(
'/ttp'
,
upload
.
any
(),
async
(
req
,
res
)
=>
{
console
.
log
(
"Getting python code.."
);
let
python_code
=
req
.
body
.
transcript_data
;
let
python_code
=
await
TextToPython
(
req
.
body
.
transcript_data
)
;
console
.
log
(
"Pyton code: "
+
python_code
);
res
.
status
(
200
).
send
(
python_code
);
});
...
...
Please
register
or
login
to post a comment