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
7c2333cd
Commit
7c2333cd
authored
Aug 29, 2023
by
Sumudu-Himasha-Ranaweera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
parent
35bc743f
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
857 additions
and
46 deletions
+857
-46
Project/Backend/Server_Python/controllers/video_translate_server.py
...ckend/Server_Python/controllers/video_translate_server.py
+92
-0
Project/Backend/Server_Python/services/audio.wav
Project/Backend/Server_Python/services/audio.wav
+0
-0
Project/Backend/Server_Python/services/video_translate.py
Project/Backend/Server_Python/services/video_translate.py
+105
-0
Project/Frontend/SignConnectPlus/package.json
Project/Frontend/SignConnectPlus/package.json
+7
-2
Project/Frontend/SignConnectPlus/src/pages/services/SignLanguageToText.js
.../SignConnectPlus/src/pages/services/SignLanguageToText.js
+12
-0
Project/Frontend/SignConnectPlus/src/pages/services/VideoToSignLanguage.js
...SignConnectPlus/src/pages/services/VideoToSignLanguage.js
+12
-0
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx
.../video-to-sign-language/VideoTranslate/VideoTranslate.tsx
+210
-41
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/Video_trasnlator.tsx
...ideo-to-sign-language/VideoTranslate/Video_trasnlator.tsx
+183
-0
Project/Frontend/SignConnectPlus/yarn.lock
Project/Frontend/SignConnectPlus/yarn.lock
+236
-3
No files found.
Project/Backend/Server_Python/controllers/video_translate_server.py
0 → 100644
View file @
7c2333cd
from
fastapi
import
FastAPI
,
HTTPException
from
pymongo.mongo_client
import
MongoClient
from
pydantic
import
BaseModel
from
typing
import
List
from
bson
import
ObjectId
app
=
FastAPI
()
# 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"
]
class
ItemCreate
(
BaseModel
):
item_name
:
str
item_description
:
str
class
Item
(
BaseModel
):
item_name
:
str
item_description
:
str
_id
:
str
class
TranslatedItemCreate
(
BaseModel
):
translated_integer_si
:
str
@
app
.
on_event
(
"startup"
)
async
def
startup_db_client
():
app
.
mongodb_client
=
MongoClient
(
uri
)
try
:
app
.
mongodb_client
.
admin
.
command
(
"ping"
)
print
(
"Pinged your deployment. You successfully connected to MongoDB!"
)
except
Exception
as
e
:
print
(
e
)
@
app
.
on_event
(
"shutdown"
)
async
def
shutdown_db_client
():
app
.
mongodb_client
.
close
()
@
app
.
get
(
"/"
)
async
def
read_root
():
return
{
"message"
:
"FastAPI with MongoDB integration"
}
# send tranlated integer to mongodb
@
app
.
post
(
"/translated_items/"
,
response_model
=
TranslatedItemCreate
)
async
def
create_translated_item
(
translated_item_create
:
TranslatedItemCreate
):
translated_item_data
=
{
"translated_integer_si"
:
translated_item_create
.
translated_integer_si
,
}
result
=
items_collection
.
insert_one
(
translated_item_data
)
if
result
.
inserted_id
:
# return translated_item_data
return
{
**
translated_item_data
,
"_id"
:
str
(
result
.
inserted_id
)}
else
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"Failed to create translated item"
)
@
app
.
put
(
"/items/{item_id}"
,
response_model
=
Item
)
async
def
update_item
(
item_id
:
str
,
item_update
:
ItemCreate
):
item_object_id
=
ObjectId
(
item_id
)
# Convert item_id to ObjectId
update_data
=
{
"item_name"
:
item_update
.
item_name
,
"item_description"
:
item_update
.
item_description
,
}
result
=
items_collection
.
update_one
({
"_id"
:
item_object_id
},
{
"$set"
:
update_data
})
if
result
.
modified_count
>
0
:
updated_item
=
items_collection
.
find_one
({
"_id"
:
item_object_id
})
return
{
**
updated_item
,
"_id"
:
str
(
updated_item
[
"_id"
])}
else
:
raise
HTTPException
(
status_code
=
404
,
detail
=
"Item not found"
)
@
app
.
get
(
"/items/"
,
response_model
=
List
[
Item
])
async
def
get_all_items
():
items
=
list
(
items_collection
.
find
())
items_with_string_id
=
[{
**
item
,
"_id"
:
str
(
item
[
"_id"
])}
for
item
in
items
]
print
(
items_with_string_id
)
return
items_with_string_id
if
__name__
==
"__main__"
:
import
uvicorn
uvicorn
.
run
(
app
,
host
=
"127.0.0.1"
,
port
=
8000
)
Project/Backend/Server_Python/services/audio.wav
0 → 100644
View file @
7c2333cd
File added
Project/Backend/Server_Python/services/video_translate.py
0 → 100644
View file @
7c2333cd
import
moviepy.editor
as
mp
import
speech_recognition
as
sr
import
tkinter
as
tk
from
tkinter
import
filedialog
from
tkinter
import
messagebox
from
tkinter
import
scrolledtext
import
requests
from
bson
import
ObjectId
import
urllib.parse
import
subprocess
# Define a dictionary to map Sinhala Unicode to integers
unicode_to_int_mapping
=
{
"මම"
:
1
,
"හෙට"
:
2
,
"යනවා"
:
3
,
"මං"
:
4
}
def
translate_text
(
text
,
target_language
):
url
=
"https://translate.googleapis.com/translate_a/single"
params
=
{
"client"
:
"gtx"
,
"sl"
:
"auto"
,
"tl"
:
target_language
,
"dt"
:
"t"
,
"q"
:
text
}
response
=
requests
.
get
(
url
,
params
=
params
)
translation_data
=
response
.
json
()
translated_text
=
translation_data
[
0
][
0
][
0
]
return
translated_text
# send to service.py
def
send_to_service
(
translated_integer_si
):
url
=
"http://127.0.0.1:8000/translated_items/"
data
=
{
"translated_integer_si"
:
translated_integer_si
,
}
response
=
requests
.
post
(
url
,
json
=
data
)
if
response
.
status_code
==
200
:
print
(
"Data sent to server successfully"
)
else
:
print
(
"Failed to send data to server"
)
def
convert_video
():
video_path
=
filedialog
.
askopenfilename
(
filetypes
=
[(
"Video Files"
,
"*.mp4"
)])
if
not
video_path
:
messagebox
.
showwarning
(
"Warning"
,
"No video file selected."
)
return
try
:
audio_save_path
=
"audio.wav"
video
=
mp
.
VideoFileClip
(
video_path
)
audio
=
video
.
audio
audio
.
write_audiofile
(
audio_save_path
)
r
=
sr
.
Recognizer
()
with
sr
.
AudioFile
(
audio_save_path
)
as
source
:
audio
=
r
.
record
(
source
)
recognized_text
=
r
.
recognize_google
(
audio
,
language
=
'si-LK'
)
translated_text_si
=
translate_text
(
recognized_text
,
"si"
)
translated_text_en
=
translate_text
(
recognized_text
,
"en"
)
# Get the integer values and join them into a single string
translated_integer_si
=
' '
.
join
(
str
(
unicode_to_int_mapping
.
get
(
word
,
0
))
for
word
in
translated_text_si
.
split
())
print
(
"Translated Integer (Si):"
,
translated_integer_si
)
# Print the translated integer
send_to_service
(
translated_integer_si
)
# Sending translated_integer_si
textarea_si
.
delete
(
'1.0'
,
tk
.
END
)
textarea_en
.
delete
(
'1.0'
,
tk
.
END
)
textarea_si
.
insert
(
tk
.
END
,
f
"Translated Integer: {translated_integer_si}
\n
{translated_text_si}"
)
textarea_en
.
insert
(
tk
.
END
,
translated_text_en
)
except
Exception
as
e
:
messagebox
.
showerror
(
"Error"
,
str
(
e
))
print
(
"Error during video conversion:"
,
e
)
if
__name__
==
"__main__"
:
# subprocess.Popen(["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "8050"])
window
=
tk
.
Tk
()
window
.
title
(
"Video Translation"
)
window
.
geometry
(
"800x600"
)
title_label
=
tk
.
Label
(
window
,
text
=
"Video Translation"
,
font
=
(
"Arial"
,
16
,
"bold"
))
title_label
.
pack
(
pady
=
10
)
convert_button
=
tk
.
Button
(
window
,
text
=
"Convert Video"
,
command
=
convert_video
)
convert_button
.
pack
(
pady
=
10
)
textarea_si_label
=
tk
.
Label
(
window
,
text
=
"Sinhala Unicode Translation"
)
textarea_si_label
.
pack
()
textarea_si
=
scrolledtext
.
ScrolledText
(
window
,
wrap
=
tk
.
WORD
,
width
=
80
,
height
=
10
)
textarea_si
.
pack
()
textarea_en_label
=
tk
.
Label
(
window
,
text
=
"Singlish Translation"
)
textarea_en_label
.
pack
()
textarea_en
=
scrolledtext
.
ScrolledText
(
window
,
wrap
=
tk
.
WORD
,
width
=
80
,
height
=
10
)
textarea_en
.
pack
()
window
.
mainloop
()
Project/Frontend/SignConnectPlus/package.json
View file @
7c2333cd
...
...
@@ -54,6 +54,7 @@
"jwt-decode"
:
"^3.1.2"
,
"lodash"
:
"^4.17.21"
,
"match-sorter"
:
"^6.3.1"
,
"mui-file-input"
:
"^3.0.0"
,
"notistack"
:
"^3.0.1"
,
"process"
:
"^0.11.10"
,
"react"
:
"^18.2.0"
,
...
...
@@ -105,7 +106,11 @@
"util"
:
"^0.12.5"
,
"uuid"
:
"^9.0.0"
,
"web-vitals"
:
"^3.3.1"
,
"yup"
:
"^1.1.1"
"yup"
:
"^1.1.1"
,
"@material-ui/core"
:
"^4.12.4"
,
"@mui/icons-material"
:
"^5.14.6"
,
"react-material-file-upload"
:
"^0.0.4"
,
"react-webcam"
:
"^7.1.1"
},
"scripts"
:
{
"start"
:
"react-app-rewired start"
,
...
...
@@ -177,4 +182,4 @@
"react-error-overlay"
:
"6.0.11"
,
"typescript"
:
"^5.0.4"
}
}
\ No newline at end of file
}
Project/Frontend/SignConnectPlus/src/pages/services/SignLanguageToText.js
0 → 100644
View file @
7c2333cd
import
axios
from
'
axios
'
;
class
SignLanguageToTextService
{
predictSignLanguageVideo
(
speed
,
data
)
{
return
axios
.
post
(
`http://127.0.0.1:8000/predict-sign-language/video/speed_levels?speed=
${
speed
}
`
,
data
);
}
}
export
default
new
SignLanguageToTextService
();
Project/Frontend/SignConnectPlus/src/pages/services/VideoToSignLanguage.js
0 → 100644
View file @
7c2333cd
import
axios
from
'
axios
'
;
class
VideoToSignLanguage
{
videoTranslation
(
data
)
{
return
axios
.
post
(
`http://127.0.0.1:8000/predict-sign-language/video/speed_levels?speed=
${
speed
}
`
,
data
);
}
}
export
default
new
VideoToSignLanguage
();
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/VideoTranslate.tsx
View file @
7c2333cd
This diff is collapsed.
Click to expand it.
Project/Frontend/SignConnectPlus/src/pages/video-to-sign-language/VideoTranslate/Video_trasnlator.tsx
0 → 100644
View file @
7c2333cd
// import { Alert, Button, Card, CardActions, CardContent, CardHeader, Container, Grid, Typography } from '@mui/material';
// import Head from 'next/head';
// import { useCallback, useState } from 'react';
// import { ComingSoonIllustration } from 'assets/illustrations';
// import CustomBreadcrumbs from 'components/custom-breadcrumbs/CustomBreadcrumbs';
// import Iconify from 'components/iconify/Iconify';
// import HomeWidget from 'sections/@dashboard/spokenLanguageTranslation-module/HomeWidget';
// import _mock from '../../../_mock';
// import Editor from '../../../components/editor';
// import { useSettingsContext } from '../../../components/settings';
// import { Upload } from '../../../components/upload';
// import DashboardLayout from '../../../layout/dashboard';
// import {
// CarouselBasic3
// } from '../../../sections/_examples/extra/carousel';
// SpokenLanguageTranslationHomePage.getLayout = (page: React.ReactElement) => <DashboardLayout>{page}</DashboardLayout>;
// export default function SpokenLanguageTranslationHomePage() {
// const { themeStretch } = useSettingsContext();
// const [translateType, setTranslateType] = useState<"video" | "text">()
// const [file, setFile] = useState<File | string | null>(null);
// const [quillSimple, setQuillSimple] = useState('');
// const handleHomeWidgetOnClick = (value: string) => {
// if (!value) return
// if (value == "Video Translate") {
// setTranslateType("video")
// return
// }
// if (value == "Text Translate") {
// setTranslateType("text")
// return
// }
// }
// const handleDropSingleFile = useCallback((acceptedFiles: File[]) => {
// const file = acceptedFiles[0];
// if (file) {
// setFile(
// Object.assign(file, {
// preview: URL.createObjectURL(file),
// })
// );
// }
// }, []);
// const _carouselsExample = [...Array(5)].map((_, index) => ({
// id: _mock.id(index),
// title: _mock.text.title(index),
// image: _mock.image.cover(index),
// description: _mock.text.description(index),
// }));
// return (
// <>
// <Head>
// <title> Spoken Language Translation Home | SignLink </title>
// </Head>
// <Container maxWidth={themeStretch ? false : 'xl'}>
// <CustomBreadcrumbs
// heading="Spoken Language Translation"
// links={[
// {
// name: 'Dashboard',
// href: '#',
// icon: <Iconify icon="eva:home-fill" />,
// },
// { name: 'Spoken Language Translation Module', href: '#', icon: <Iconify icon="eva:cube-outline" /> },
// { name: 'Spoken Language Translation', icon: <Iconify icon="eva:cube-outline" /> },
// ]}
// />
// </Container>
// <Container maxWidth={themeStretch ? false : 'xl'}>
// <Grid container spacing={2} rowSpacing={3}>
// <Grid item xs={12} md={6} lg={6}>
// <HomeWidget
// title="Video Translate"
// subTitle="Spoken Language Video Convert to sign language"
// icon="eva:video-fill"
// color='warning'
// handleClick={handleHomeWidgetOnClick}
// />
// </Grid>
// <Grid item xs={12} md={6} lg={6}>
// <HomeWidget
// title="Text Translate"
// subTitle="Spoken Language Text Convert to sign language"
// icon="eva:text-fill"
// color="success"
// handleClick={handleHomeWidgetOnClick}
// />
// </Grid>
// {!translateType && <>
// <Grid item xs={12} md={12} lg={12}>
// <Alert severity='info' >Select a Translation type</Alert>
// </Grid>
// </>}
// {translateType == "video" && <>
// <Grid item xs={12} md={8} lg={8}>
// <Card>
// <CardHeader
// title="Upload Video"
// subheader="Upload you're video to convert to sigh language"
// />
// <CardContent>
// <Upload file={file} onDrop={handleDropSingleFile} onDelete={() => setFile(null)} />
// </CardContent>
// <CardActions>
// <Button variant="contained" color='error' fullWidth onClick={() => { setFile(null) }}>
// Reset
// </Button>
// <Button variant="contained" fullWidth>
// Convert
// </Button>
// </CardActions>
// </Card>
// </Grid>
// <Grid item xs={12} md={4} lg={4}>
// <Card>
// <CardHeader title="3D Model" />
// <CardContent>
// <Typography variant="h3" paragraph>
// Coming Soon!
// </Typography>
// <Typography sx={{ color: 'text.secondary' }}>
// We are currently working hard on this page!
// </Typography>
// <ComingSoonIllustration sx={{ my: 1, height: 200 }} />
// </CardContent>
// </Card>
// </Grid>
// </>}
// {translateType == "text" && <>
// <Grid item xs={12} md={8} lg={8}>
// <Card sx={{ height: "100%" }}>
// <CardHeader
// title="Enter text"
// subheader="Enter you're text to convert to sigh language"
// />
// <CardContent>
// <Editor
// simple
// id="simple-editor"
// value={quillSimple}
// onChange={(value) => setQuillSimple(value)}
// />
// </CardContent>
// <CardActions>
// <Button variant="contained" color='error' fullWidth onClick={() => { setQuillSimple('') }}>
// Reset
// </Button>
// <Button variant="contained" fullWidth>
// Convert
// </Button>
// </CardActions>
// </Card>
// </Grid>
// <Grid item xs={12} md={4} lg={4}>
// <Card>
// <CardHeader title="Converted Output" />
// <CardContent>
// <CarouselBasic3 data={_carouselsExample} />
// </CardContent>
// </Card>
// </Grid>
// </>}
// </Grid>
// </Container>
// </>
// );
// }
Project/Frontend/SignConnectPlus/yarn.lock
View file @
7c2333cd
This diff is collapsed.
Click to expand it.
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