Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SinLingua Toolkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2023-118
SinLingua Toolkit
Commits
70eacf1f
Commit
70eacf1f
authored
Aug 22, 2023
by
SupunGurusinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added audio feature
parent
e9b8d22f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
9 deletions
+39
-9
app.py
app.py
+17
-4
templates/index.html
templates/index.html
+22
-5
No files found.
app.py
View file @
70eacf1f
...
...
@@ -9,8 +9,14 @@ def index():
if
request
.
method
==
'POST'
:
input_text
=
request
.
form
.
get
(
'input_text'
)
# Perform processing on input_text and set processed_result
processed_result
=
f
"Processed: {input_text}"
# Example processing
audio_input
=
request
.
files
.
get
(
'audio_input'
)
if
input_text
:
# Perform text processing on input_text
processed_result
=
f
"Processed: {input_text}"
# Example text processing
elif
audio_input
:
# Perform audio processing
processed_result
=
"Audio Collected"
return
render_template
(
'index.html'
,
processed_result
=
processed_result
)
...
...
@@ -18,8 +24,15 @@ def index():
@
app
.
route
(
'/process'
,
methods
=
[
'POST'
])
def
process
():
input_text
=
request
.
form
.
get
(
'input_text'
)
# Perform processing on input_text and set processed_result
processed_result
=
f
"{input_text}"
# Example processing
audio_input
=
request
.
files
.
get
(
'audio_input'
)
if
input_text
:
# Perform text processing on input_text
processed_result
=
f
"{input_text}"
# Example text processing
elif
audio_input
:
# Perform audio processing
processed_result
=
"Audio Collected"
return
jsonify
({
'processed_result'
:
processed_result
})
...
...
templates/index.html
View file @
70eacf1f
...
...
@@ -6,14 +6,17 @@
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
>
</head>
<body>
<webview
src=
"http://localhost:5000"
style=
"width: 100%; height: 100%;"
></webview>
<div
class=
"container mt-5"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<form
id=
"inputForm"
>
<form
id=
"inputForm"
enctype=
"multipart/form-data"
>
<div
class=
"form-group"
>
<label
for=
"inputText"
>
Enter Text:
</label>
<textarea
class=
"form-control"
id=
"inputText"
rows=
"5"
></textarea>
<label
for=
"inputText"
>
Enter Text or Upload Audio:
</label>
<textarea
class=
"form-control"
id=
"inputText"
name=
"input_text"
rows=
"5"
></textarea>
<div
class=
"custom-file"
>
<input
type=
"file"
accept=
"audio/*"
class=
"custom-file-input"
id=
"audioInput"
name=
"audio_input"
>
<label
class=
"custom-file-label"
for=
"audioInput"
>
Choose File
</label>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Process
</button>
</form>
...
...
@@ -34,10 +37,18 @@
$
(
'
#inputForm
'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
var
inputText
=
$
(
'
#inputText
'
).
val
();
var
audioInput
=
$
(
'
#audioInput
'
)[
0
].
files
[
0
];
// Get the selected audio file
var
formData
=
new
FormData
();
formData
.
append
(
'
input_text
'
,
inputText
);
formData
.
append
(
'
audio_input
'
,
audioInput
);
$
.
ajax
({
type
:
'
POST
'
,
url
:
'
/process
'
,
data
:
{
input_text
:
inputText
},
data
:
formData
,
contentType
:
false
,
processData
:
false
,
success
:
function
(
response
)
{
$
(
'
#processedResult
'
).
val
(
response
.
processed_result
);
}
...
...
@@ -49,6 +60,12 @@
copyText
.
select
();
document
.
execCommand
(
'
copy
'
);
});
// Display selected file name in the "Choose File" input field
$
(
'
#audioInput
'
).
change
(
function
()
{
var
fileName
=
$
(
this
).
val
().
split
(
'
\\
'
).
pop
();
$
(
this
).
siblings
(
'
.custom-file-label
'
).
addClass
(
'
selected
'
).
html
(
fileName
);
});
});
</script>
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment