Commit 9991a4e3 authored by Manoj Kumar's avatar Manoj Kumar

Amashi dev

parent 41f7865a
......@@ -15,4 +15,7 @@ dataq/mask_rcnn_coco.h5
/dataq/inference_graph
/dataset
/dataq/__pycache__
/textvoice/__pycache__
\ No newline at end of file
/textvoice/__pycache__
/reveng/core/__pycache__
/reveng/output
*.pyc
from flask import Flask, render_template, request, redirect
import json, sys, os
# sys.path.append('../reveng')
REVENG_DIR = os.path.dirname(os.path.abspath(__file__))
TEMPLATE = os.path.join(REVENG_DIR,"\\templates")
STATIC = os.path.join(REVENG_DIR,"\\static")
from reveng.test_json import printTest
from reveng.processInput import checkCommon
app = Flask(__name__,template_folder=TEMPLATE,static_folder=STATIC)
app.config["DEBUG"] = True
@app.route('/test',methods =['GET'])
def testApi():
return "<h1>The API is working</h1>"
@app.route('/',methods =['GET'])
def welcomeApi():
return "<h1>Welcome to EasyTalk API</h1>"
# REVENG
@app.route('/tts', methods=['GET'])
def textToSignLanguage():
print(TEMPLATE)
return render_template("index.html")
@app.route('/tts/response/', methods=['POST'])
def response():
message = request.get_json()
word = checkCommon(message['message'])
return redirect('/tts')
# END REVENG
host = "localhost"
app.run(host=host,port=3000)
\ No newline at end of file
{
"name": "2020_077",
"version": "1.0.0",
"description": "Web based Sign Language to Text Translator using ML ",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://gitlab.sliit.lk/2020_077/2020_077"
},
"author": "Eventors 4.0",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.3",
"python-shell": "^1.0.8",
"socket.io": "^2.3.0"
}
}
from reveng.processInput import processInput
from reveng.processSentence import processSentence
from reveng.processWord import processWord
from reveng.getImages import getImagesCommonSentence
from reveng.getImages import getImagesCommonWord
from reveng.getImages import getImagesRareWord
from reveng.checkCommon import checkInJson
......@@ -18,7 +18,7 @@ import os
#import imageio
from flask import Flask, render_template, request, jsonify, redirect, url_for, send_from_directory
from core.processInput import processInput
from processInput import processInput
from nltk.tokenize import sent_tokenize, word_tokenize
import nltk
nltk.download('punkt')
......
import json,os
from reveng.processWord import processWord
from reveng.processSentence import processSentence
REVENG = os.path.dirname(os.path.abspath(__file__))
jsonPath = os.path.join(REVENG, 'common.json')
def checkInJson(message):
message = message.lower()
with open(jsonPath) as jsonfile:
data = json.load(jsonfile)
sentences = data['sentences']
words = data['words']
common = words['common_words']
englishwords = common['english']
alphabets = data['alphabet']
english_alphabet = alphabets['english']
if message in sentences:
processSentence(message)
elif message in englishwords or message in english_alphabet:
processWord(message)
else:
print("Call Rare methods here...")
......@@ -103,7 +103,6 @@
}
},
"alphabet": {
"english_alphabet": {
"english": [
"a",
"b",
......@@ -133,5 +132,5 @@
"z"
]
}
}
}
......@@ -104,7 +104,6 @@
}
},
"alphabet": {
"english_alphabet": {
"english": [
"a",
"b",
......@@ -133,6 +132,5 @@
"y",
"z"
]
}
}
}
......@@ -3,7 +3,7 @@ from firebase_admin import credentials
from firebase_admin import storage
import PIL.Image as pigm
from core.gifMaker import generateGIF
from reveng.gifMaker import generateGIF
PATH = os.path.dirname(os.path.abspath(__file__))
JSON = os.path.join(PATH, 'credentials.json')
......@@ -61,7 +61,7 @@ def getImagesCommonWord(message):
def getImagesRareWord(message):
images = store.child().list_files()
imageRes = []
sendingToGIF = 0
for i in images:
if i.name == message + ".jpg":
print ("image name =" + i.name)
......
from core.processWord import processWord
from core.processSentence import processSentence
from reveng.processWord import processWord
from reveng.processSentence import processSentence
from reveng.checkCommon import checkInJson
def processInput(message):
msg_split = message.split(" ")
......@@ -8,8 +9,11 @@ def processInput(message):
if(len(msg_split) <= 1):
print("This is a word")
processWord(message)
return "Word"
else:
print("This is a sentence")
processSentence(message)
\ No newline at end of file
return "Sentence"
def checkCommon(message):
checkInJson(message)
\ No newline at end of file
import json,os
from core.getImages import getImagesCommonSentence
from reveng.getImages import getImagesCommonSentence
REVENG = os.path.dirname(os.path.abspath(__file__))
jsonPath = os.path.join(REVENG, 'common.json')
......
import json,os
from core.getImages import getImagesCommonWord
from core.getImages import getImagesRareWord
from core.gifMaker import generateGIF
from reveng.getImages import getImagesCommonWord
from reveng.getImages import getImagesRareWord
from reveng.gifMaker import generateGIF
REVENG = os.path.dirname(os.path.abspath(__file__))
jsonPath = os.path.join(REVENG, 'common.json')
......@@ -27,4 +27,4 @@ def processWord(message):
for item in wordArr:
imageSetArray.append(getImagesRareWord(item))
print(type(imageSetArray[0]))
generateGIF(imageSetArray)
\ No newline at end of file
generateGIF(imageSetArray)
......@@ -58,7 +58,7 @@
var message = $("#textInput").val();
e.preventDefault();
$.ajax({
url: "http://127.0.0.1:5000/response/",
url: "http://127.0.0.1:3000/tts/response/",
data: JSON.stringify({ message: message }),
method: "POST",
contentType: "application/json",
......
import json
import os
REVENG = os.path.dirname(os.path.abspath(__file__))
jsonPath = os.path.join(REVENG, 'common.json')
with open(jsonPath) as jsonfile:
data = json.load(jsonfile)
sentences = data['sentences']
common = sentences['common_sentences']
english = common['english']
# import json
# import os
# REVENG = os.path.dirname(os.path.abspath(__file__))
# jsonPath = os.path.join(REVENG, 'common.json')
# with open(jsonPath) as jsonfile:
# data = json.load(jsonfile)
# sentences = data['sentences']
# common = sentences['common_sentences']
# english = common['english']
for i in english:
print(i)
# for i in english:
# print(i)
def printTest():
return "poda punda"
\ No newline at end of file
/**
* IT17050272 01-05-2020 #1, Created
* IT17050272 14-05-2020 #2, Modified
*
*/
const express = require('express');
const app = express();
const path = require('path');
const server = require('http').Server(app);
const io = require('socket.io')(server);
const port = process.env.PORT || 5000;
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname,'index.html'));
});
setInterval(()=>{
io.emit('image','sample')
},200)
server.listen(port, () => {
console.log(`Server running on port ${port}`);
});
app.get('/test', function (req, res) {
console.log('Server working');
res.status(200).json({
"server_status": "OK"
})
})
//version 01
app.get('/google', callD_almbert);
function callD_almbert(req, res) {
var spawn = require('child_process').spawn;
console.log('Creating spawn');
var filePath = "./dataq/detect.py";
var process = spawn('python', [filePath,
"https://www.google.com"
]);
console.log('request ok!');
process.stdout.on('data',function(data){
res.send(data.toString());
});
}
// // end of version 01
// //version 02 - python script
// var pythonShell = require('python-shell');
// app.get('/dalembert/shell', callD_almbert2);
// function callD_almbert2(req, res) {
// var options = {
// args: [
// req.query.funds,
// req.query.size,
// req.query.count,
// req.query.sims
// ]
// }
// pythonShell.PythonShell.run('./test-python-module/d_alembert.py',options,function(err,data){
// if(err)
// res.send(err);
// res.status(200).json({
// "data":data
// })
// })
// }
//read from camera
html {
background-color: white;
color: black;
}
h1 {
color: black;
margin-bottom: 0;
margin-top: 0;
text-align: center;
font-size: 40px;
}
h3 {
color: black;
font-size: 20px;
margin-top: 3px;
text-align: center;
}
#chatbox {
background-color: white;
margin-left: auto;
margin-right: auto;
width: 40%;
margin-top: 60px;
}
#userInput {
margin-left: auto;
margin-right: auto;
width: 40%;
margin-top: 60px;
}
#textInput {
width: 87%;
border: none;
border-bottom: 1px solid #009688;
font-family: monospace;
font-size: 17px;
}
#buttonInput {
padding: 3px;
font-family: monospace;
font-size: 17px;
background-color: white;
color: green;
border-color: green;
border-radius: 2px;
}
#buttonInput :hover {
background-color: green;
color: white;
}
.userText {
color: black;
font-family: monospace;
font-size: 17px;
text-align: right;
line-height: 30px;
}
.userText span {
background-color: #009688;
padding: 10px;
border-radius: 2px;
}
.botText {
color: black;
font-family: monospace;
font-size: 17px;
text-align: left;
line-height: 30px;
}
.botText span {
background-color: white;
padding: 10px;
border-radius: 2px;
color: black;
}
#tidbit {
position: absolute;
bottom: 0;
right: 0;
width: 300px;
}
<!--IT17143950 16-05-2020
1, Created
for testing purposes... Do not edit without permission -->
<!DOCTYPE html>
<html>
<head>
<link
rel="stylesheet"
type="text/css"
href="{{url_for('static', filename='styles/style.css')}}"
/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<h1 style="color: black">Text to SSL Translator</h1>
<div>
<div id="chatbox">
<p class="botText">
<span
>Welcome to Text to Sign Convertor.
<br />
Enter the sentence you need to translate into SSL</span
>
</p>
</div>
<form action="" method="POST" id="form">
<div id="userInput">
<input
id="textInput"
name="msg"
maxlength="50"
placeholder="Enter text here"
/>
<br /><br />
<button id="buttonInput" type="submit">TRANSLATE</button>
</div>
</form>
<!--<p id="req"></p>-->
<!-- <img src="{{ user_image }}" alt="User Image" /> -->
</div>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
$("#textInput").keypress(function (e) {
if (e.which == 13) {
getResponseSign();
}
});
$("#buttonInput").click(function () {
getResponseSign();
});
$("#form").on("submit", function (e) {
var message = $("#textInput").val();
e.preventDefault();
$.ajax({
url: "http://127.0.0.1:3000/tts/response/",
data: JSON.stringify({ message: message }),
method: "POST",
contentType: "application/json",
success: function (message) {
var text = $("#textInput").val();
var userHtml = '<p class="userText"><span>' + text + "</span></p>";
$("#textInput").val("");
$("#chatbox").append(userHtml);
document
.getElementById("userInput")
.scrollIntoView({ block: "start", behavior: "smooth" });
},
});
});
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment