Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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-029
2023-029
Commits
1a9e57e8
Commit
1a9e57e8
authored
Oct 29, 2023
by
Sumudu-Himasha-Ranaweera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final Commit
parent
e844e5d9
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
676 additions
and
475 deletions
+676
-475
Project/Backend/README.md
Project/Backend/README.md
+1
-1
Project/Backend/Server_Python/controllers/text_to_sign_language_controller.py
...er_Python/controllers/text_to_sign_language_controller.py
+77
-0
Project/Backend/Server_Python/controllers/video_to_sign_language_controller.py
...r_Python/controllers/video_to_sign_language_controller.py
+2
-1
Project/Backend/Server_Python/main.py
Project/Backend/Server_Python/main.py
+3
-1
Project/Backend/Server_Python/node_modules/.package-lock.json
...ect/Backend/Server_Python/node_modules/.package-lock.json
+6
-0
Project/Backend/Server_Python/package-lock.json
Project/Backend/Server_Python/package-lock.json
+6
-0
Project/Frontend/SignConnectPlus/src/menu-items/application.tsx
...t/Frontend/SignConnectPlus/src/menu-items/application.tsx
+11
-1
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/TextTranslate/TextTranslate.tsx
...es/video-to-sign-language/TextTranslate/TextTranslate.tsx
+145
-0
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx
.../video-to-sign-language/VideoTranslate/VideoTranslate.tsx
+153
-279
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx.bkp
...eo-to-sign-language/VideoTranslate/VideoTranslate.tsx.bkp
+263
-191
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
+7
-0
Project/Frontend/SignConnectPlus/src/utils/locales/en.json
Project/Frontend/SignConnectPlus/src/utils/locales/en.json
+2
-1
No files found.
Project/Backend/README.md
View file @
1a9e57e8
# TMP-23-029
SLIIT Final Year Project
\ No newline at end of file
BackEnd Server
\ No newline at end of file
Project/Backend/Server_Python/controllers/text_to_sign_language_controller.py
0 → 100644
View file @
1a9e57e8
from
datetime
import
datetime
import
requests
from
fastapi
import
APIRouter
,
FastAPI
,
HTTPException
,
Query
,
Request
from
fastapi.responses
import
JSONResponse
from
pymongo.mongo_client
import
MongoClient
# Replace with your MongoDB Atlas credentials
username
=
"admin"
password
=
"JppbU6MZeHfOj7sp"
uri
=
f
"mongodb+srv://{username}:{password}@researchmanagement-appl.vzhn4.mongodb.net/?retryWrites=true&w=majority"
client
=
MongoClient
(
uri
)
db
=
client
[
"test"
]
items_collection
=
db
[
"translated_items"
]
items_collection_log
=
db
[
"translated_items_log"
]
router
=
APIRouter
()
# Your unicode_to_int_mapping dictionary
unicode_to_int_mapping
=
{
"මම"
:
1
,
"හෙට"
:
2
,
"යනවා"
:
3
,
"මං"
:
4
,
"ගුඩ්"
:
5
,
"මෝනිං"
:
6
,
"උඹ"
:
7
,
"ආවේ"
:
8
,
"ඇයි"
:
9
,
}
@
router
.
post
(
"/rest_pyton/get_user_input_text"
)
async
def
get_user_input_text
(
request_data
:
dict
):
user_input_text
=
request_data
.
get
(
"userInputText"
)
if
user_input_text
is
None
:
raise
HTTPException
(
status_code
=
400
,
detail
=
"Invalid JSON data. Missing 'userInputText' field."
)
result
=
convert_text_to_numbers
(
user_input_text
)
# Send translated integer to MongoDB
send_to_mongodb
(
result
)
# Perform any processing you need on the number_array
response
=
{
"message"
:
f
"Received user input text: {user_input_text}"
,
"translated_integers_string"
:
result
}
return
response
def
send_to_mongodb
(
translated_integer_si
):
translated_item_data
=
{
"translated_integer_si"
:
translated_integer_si
,
"timestamp"
:
datetime
.
utcnow
(),
}
# Save the previous record to the log before updating
existing_record
=
items_collection
.
find_one
()
if
existing_record
:
items_collection_log
=
db
[
"translated_items_log"
]
# Exclude the _id field to allow MongoDB to generate a new one
existing_record
.
pop
(
"_id"
,
None
)
items_collection_log
.
insert_one
(
existing_record
)
# Update the existing record or create a new one
result
=
items_collection
.
replace_one
({},
translated_item_data
,
upsert
=
True
)
if
result
.
matched_count
==
0
and
result
.
modified_count
==
0
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"Failed to update or create translated item"
)
def
convert_text_to_numbers
(
user_input_text
):
words
=
user_input_text
.
split
()
numbers
=
[
unicode_to_int_mapping
.
get
(
word
,
-
1
)
for
word
in
words
]
# -1 if word not found
number_string
=
' '
.
join
([
str
(
num
)
for
num
in
numbers
if
num
!=
-
1
])
return
number_string
\ No newline at end of file
Project/Backend/Server_Python/controllers/video_to_sign_language_controller.py
View file @
1a9e57e8
...
...
@@ -68,7 +68,7 @@ async def uploaded_video(file: UploadFile = File(...)):
str
(
unicode_to_int_mapping
.
get
(
word
,
"0"
))
for
word
in
translated_text_si
.
split
()
)
print
(
"Translated Integer (Si):"
,
translated_integer_si
)
print
(
"Translated Integer (Si)
from Video
:"
,
translated_integer_si
)
# Send translated integer to MongoDB
send_to_mongodb
(
translated_integer_si
)
...
...
@@ -146,6 +146,7 @@ def send_to_mongodb(translated_integer_si):
existing_record
=
items_collection
.
find_one
()
if
existing_record
:
items_collection_log
=
db
[
"translated_items_log"
]
# Exclude the _id field to allow MongoDB to generate a new one
existing_record
.
pop
(
"_id"
,
None
)
items_collection_log
.
insert_one
(
existing_record
)
...
...
Project/Backend/Server_Python/main.py
View file @
1a9e57e8
...
...
@@ -4,7 +4,8 @@ from controllers import (
users_controller
,
video_to_sign_language_controller
,
audio_detect_controler
,
video_detect_controler
video_detect_controler
,
text_to_sign_language_controller
)
from
fastapi.responses
import
RedirectResponse
from
fastapi.middleware.cors
import
CORSMiddleware
...
...
@@ -46,6 +47,7 @@ app.include_router(translate_controler.router)
app
.
include_router
(
video_to_sign_language_controller
.
router
)
app
.
include_router
(
audio_detect_controler
.
router
)
app
.
include_router
(
video_detect_controler
.
router
)
app
.
include_router
(
text_to_sign_language_controller
.
router
)
# Add cores middleware
...
...
Project/Backend/Server_Python/node_modules/.package-lock.json
0 → 100644
View file @
1a9e57e8
{
"name"
:
"Server_Python"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{}
}
Project/Backend/Server_Python/package-lock.json
0 → 100644
View file @
1a9e57e8
{
"name"
:
"Server_Python"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{}
}
Project/Frontend/SignConnectPlus/src/menu-items/application.tsx
View file @
1a9e57e8
...
...
@@ -17,6 +17,7 @@ import {
TranslationOutlined
,
UserOutlined
,
VideoCameraOutlined
,
HighlightOutlined
,
}
from
'
@ant-design/icons
'
;
// type
...
...
@@ -37,7 +38,8 @@ const icons = {
FastForwardOutlined
,
RedditOutlined
,
AudioOutlined
,
VideoCameraOutlined
VideoCameraOutlined
,
HighlightOutlined
};
// ==============================|| MENU ITEMS - SUPPORT ||============================== //
...
...
@@ -93,6 +95,14 @@ const application: NavItemType = {
title
:
<
FormattedMessage
id=
"video-translate"
/>,
type
:
'
item
'
,
url
:
'
/video-to-sign-language/VideoTranslate
'
,
// icon: icons.VideoCameraOutlined,
},
{
id
:
'
text-translate
'
,
title
:
<
FormattedMessage
id=
"text-translate"
/>,
type
:
'
item
'
,
url
:
'
/video-to-sign-language/text-translation
'
,
// icon: icons.HighlightOutlined,
}
]
},
...
...
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/TextTranslate/TextTranslate.tsx
0 → 100644
View file @
1a9e57e8
// material-ui
import
{
Button
,
Divider
,
Grid
,
InputLabel
,
Stack
,
TextField
}
from
'
@mui/material
'
;
import
{
LocalizationProvider
}
from
'
@mui/x-date-pickers
'
;
import
{
AdapterDateFns
}
from
'
@mui/x-date-pickers/AdapterDateFns
'
;
import
axios
from
'
axios
'
;
import
MainCard
from
'
components/MainCard
'
;
// third-party
import
{
Form
,
FormikProvider
,
useFormik
}
from
'
formik
'
;
import
{
useState
}
from
'
react
'
;
import
*
as
Yup
from
'
yup
'
;
// project imports
// assets
// types
// ==============================|| List ||============================== //
const
TextTranslate
=
()
=>
{
const
[
showUnityWebGL
,
setShowUnityWebGL
]
=
useState
(
false
);
const
FormSchema
=
Yup
.
object
().
shape
({
userInputText
:
Yup
.
string
()
.
required
(
'
Field is required
'
)
.
test
(
'
is-sinhala
'
,
'
Input must be in Sinhala
'
,
(
value
)
=>
{
// You can use a regular expression or any custom logic to validate Sinhala text.
// Here's a basic example using a regular expression for Sinhala characters.
const
sinhalaRegex
=
/^
[\u
0D80-
\u
0DFF
\s]
+$/
;
// Range for Sinhala Unicode characters
if
(
!
value
)
{
// If the field is empty, it's valid as it's already being checked by 'required'
return
true
;
}
return
sinhalaRegex
.
test
(
value
);
})
.
max
(
255
,
'
Input must be at most 255 characters long
'
),
});
const
formik
=
useFormik
({
initialValues
:
{
userInputText
:
""
,
},
validationSchema
:
FormSchema
,
enableReinitialize
:
true
,
onSubmit
:
async
(
values
,
{
setSubmitting
,
resetForm
})
=>
{
try
{
// API Call Here
const
response
=
await
axios
.
post
(
"
http://127.0.0.1:8000/rest_pyton/get_user_input_text
"
,
{
userInputText
:
values
.
userInputText
,
});
// Check if the request was successful
if
(
response
.
status
===
200
)
{
console
.
log
(
"
Success:
"
,
response
.
data
);
setShowUnityWebGL
(
true
)
}
else
{
console
.
error
(
"
Request failed with status code:
"
,
response
.
status
);
}
resetForm
()
setSubmitting
(
false
);
}
catch
(
error
)
{
console
.
error
(
error
);
}
}
});
const
{
errors
,
touched
,
handleSubmit
,
isSubmitting
,
getFieldProps
}
=
formik
;
return
(
<>
<
FormikProvider
value=
{
formik
}
>
<
LocalizationProvider
dateAdapter=
{
AdapterDateFns
}
>
<
Form
autoComplete=
"off"
noValidate
onSubmit=
{
handleSubmit
}
>
<
MainCard
>
<
Grid
container
spacing=
{
3
}
>
<
Grid
item
xs=
{
4
}
md=
{
4
}
>
<
Grid
container
spacing=
{
3
}
>
<
Grid
item
xs=
{
12
}
>
<
Stack
spacing=
{
1.25
}
>
<
InputLabel
htmlFor=
"userInputText"
>
Enter Text to Translate
</
InputLabel
>
<
TextField
fullWidth
id=
"userInputText"
placeholder=
"Enter Text Name"
{
...
getFieldProps
('
userInputText
')}
error=
{
Boolean
(
touched
.
userInputText
&&
errors
.
userInputText
)
}
helperText=
{
touched
.
userInputText
&&
errors
.
userInputText
}
/>
</
Stack
>
</
Grid
>
<
Grid
item
xs=
{
12
}
>
<
Divider
/>
</
Grid
>
<
Grid
item
xs=
{
12
}
>
<
Grid
container
justifyContent=
"space-between"
alignItems=
"center"
>
<
Grid
item
>
</
Grid
>
<
Grid
item
>
<
Stack
direction=
"row"
spacing=
{
2
}
alignItems=
"center"
>
<
Button
color=
"error"
onClick=
{
()
=>
{
setShowUnityWebGL
(
false
)
}
}
>
Cancel
</
Button
>
<
Button
type=
"submit"
variant=
"contained"
disabled=
{
isSubmitting
}
>
TRANSLATE
</
Button
>
</
Stack
>
</
Grid
>
</
Grid
>
</
Grid
>
</
Grid
>
</
Grid
>
<
Grid
item
xs=
{
8
}
md=
{
8
}
>
{
showUnityWebGL
?
<
iframe
// src="https://64f66d39fdef493229b2ddd9--lambent-unicorn-97396a.netlify.app/"
src=
"https://64f7cfd336356b18eb42de2b--lambent-unicorn-97396a.netlify.app/"
width=
"100%"
height=
"700px"
// Adjust the height as needed
title=
"Unity WebGL"
style=
{
{
border
:
'
none
'
,
overflow
:
'
hidden
'
}
}
></
iframe
>
:
<>
3D model Rendered Here...
</>
}
</
Grid
>
</
Grid
>
</
MainCard
>
</
Form
>
</
LocalizationProvider
>
</
FormikProvider
>
</>
);
};
export
default
TextTranslate
;
\ No newline at end of file
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx
View file @
1a9e57e8
This diff is collapsed.
Click to expand it.
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx.bkp
View file @
1a9e57e8
This diff is collapsed.
Click to expand it.
Project/Frontend/SignConnectPlus/src/routes/MainRoutes.tsx
View file @
1a9e57e8
...
...
@@ -49,6 +49,8 @@ const TutorialManagementList = Loadable(lazy(() => import('pages/parameter/tutor
// render - Video to Sign Language page
const
VideoTranslation
=
Loadable
(
lazy
(()
=>
import
(
'
pages/video-to-sign-language/VideoTranslate/VideoTranslate
'
)));
// render - Text to Sign Language page
const
TextTranslation
=
Loadable
(
lazy
(()
=>
import
(
'
pages/video-to-sign-language/TextTranslate/TextTranslate
'
)));
// render - audio-detection page
const
AudioDetection
=
Loadable
(
lazy
(()
=>
import
(
'
pages/emotion-detection/emotion-audio-detection/list/list
'
)));
...
...
@@ -128,9 +130,14 @@ const MainRoutes = {
{
path
:
'
VideoTranslate
'
,
element
:
<
VideoTranslation
/>
},
{
path
:
'
text-translation
'
,
element
:
<
TextTranslation
/>
}
]
},
{
path
:
'
learning-management
'
,
children
:
[
...
...
Project/Frontend/SignConnectPlus/src/utils/locales/en.json
View file @
1a9e57e8
...
...
@@ -168,5 +168,6 @@
"learning-dashboard"
:
"Dashboard"
,
"learning-curriculums-subscribed-tutorial"
:
"Tutorial"
,
"video-to-sign-language"
:
"Sign Language Translate"
,
"video-translate"
:
"Video Translator"
"video-translate"
:
"Video Translation"
,
"text-translate"
:
"Text Translation"
}
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