-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Gerroll/develop
Develop
- Loading branch information
Showing
54 changed files
with
16,017 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Pycharm/Intellij | ||
.idea | ||
|
||
# NLP Model | ||
naturalLanguageProcessing/nlp_model/ | ||
|
||
# Pipfile lock | ||
Pipfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
flask = "*" | ||
spacy = "*" | ||
ffmpeg = "*" | ||
pydub = "*" | ||
pandas = "*" | ||
fr-core-news-sm = {file = "https://github.com/explosion/spacy-models/releases/download/fr_core_news_sm-2.3.0/fr_core_news_sm-2.3.0.tar.gz"} | ||
numpy = "*" | ||
requests = "*" | ||
gunicorn = "*" | ||
speechrecognition = "*" | ||
rq = "*" | ||
redis = "*" | ||
matplotlib = "*" | ||
networkx = "*" | ||
|
||
[requires] | ||
python_version = "3.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn app:app --preload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,58 @@ | ||
# T-AIA_901 | ||
Voice recognition to return the optimal train route between two destination | ||
|
||
## Launch the web app in dev mode | ||
`export FLASK_ENV=development` | ||
|
||
`flask run` | ||
|
||
## Launch app | ||
`python app.py` | ||
|
||
## Launch test | ||
`python test.py` | ||
|
||
## Using Virtualenv | ||
### Install virtual env | ||
`pip install virtualenv` | ||
|
||
### Init virtualenv | ||
`virtualenv -p python3.7 venv3.7` | ||
|
||
### Use existing virtualenv | ||
Ubuntu : | ||
`source venv3.7/bin/activate` | ||
|
||
Windows: | ||
`venv3.7\Scripts\activate.bat` | ||
|
||
### Install package in virtualenv | ||
`pip install <module>` | ||
|
||
### Save dependencies | ||
`pip freeze > requirements3.7.txt` | ||
|
||
### Load dependencies | ||
`pip install -r requirements3.7.txt` | ||
|
||
### Stop using virtualenv | ||
`deactivate` | ||
|
||
## Using [Pipenv](https://pipenv.pypa.io/en/latest/) | ||
### Install pipenv | ||
`pip install --user pipenv` | ||
|
||
### Init project with python 3.7 | ||
`pipenv --python path/to/python3.7` | ||
|
||
### Install dependencies from requirements.txt | ||
`pipenv install -r requirements.txt` | ||
|
||
### Install package | ||
`pipenv install <module>` | ||
|
||
### Activate environnement | ||
`pipenv shell` | ||
|
||
### Run program | ||
`pipenv run python3 app.py` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# Project libs | ||
from naturalLanguageProcessing import Nlp | ||
from pathFindingProcessing import PathFinder | ||
from voiceProcessing import VoiceProcessing | ||
from controllers import MainController | ||
import speech_recognition as sr | ||
|
||
# Others | ||
import sys | ||
import os | ||
import requests | ||
|
||
# Flask | ||
from flask import Flask, session, request, render_template, redirect, url_for | ||
|
||
app = Flask(__name__) | ||
|
||
# Set the secret key to some random bytes. Keep this really secret! | ||
app.secret_key = b'_8#y2o"J4Q9z\n\xec]/' | ||
|
||
# initialise components | ||
VP = VoiceProcessing() | ||
NLP = Nlp() | ||
PF = PathFinder() | ||
print('Done initialisation component') | ||
|
||
def resetNlp(): | ||
NLP = Nlp() | ||
NLP.reset() | ||
NLP.train() | ||
NLP.test() | ||
|
||
""" Reset Nlp route """ | ||
@app.route('/reset') | ||
def reset(): | ||
resetNlp() | ||
|
||
return "Nlp a été reset avec succès." | ||
|
||
""" Home route """ | ||
@app.route('/') | ||
def home(): | ||
# generate uniq id for our user | ||
if 'userId' not in session: | ||
userId = os.urandom(16) | ||
session['userId'] = userId | ||
|
||
# clean session for result | ||
if 'result' in session: | ||
session.pop('result') | ||
|
||
|
||
# render home page | ||
return render_template('home.html') | ||
|
||
""" Result route """ | ||
@app.route('/result') | ||
def result(): | ||
# store it in session | ||
if 'userId' in session and 'result' in session: | ||
# render result page | ||
return render_template('result.html') | ||
else: | ||
return redirect(url_for('home')) | ||
|
||
""" Process route """ | ||
@app.route('/process', methods=['POST']) | ||
def process(): | ||
# clean session errors | ||
if 'errors' in session: | ||
session.pop('errors') | ||
userId = request.form['userId'] | ||
audio = request.files['audio'] | ||
# get the userId in request args and check it's egal to our session['userId] | ||
if session['userId'] and str(userId) == str(session['userId']): | ||
# initialise main controller | ||
processor = MainController(VP, NLP, PF) | ||
# dispatch request | ||
res = processor.process_audio(audio) | ||
|
||
if int(res[1]) == 666: # Error | ||
# save error message to session | ||
session['errors'] = res[0] | ||
else: | ||
# save result to session | ||
session['result'] = res[0] | ||
|
||
# return result status | ||
return dict({'status': res[1]}) | ||
else: | ||
return dict({'status': 401}) | ||
|
||
|
||
|
||
""" Main program """ | ||
def main(): | ||
|
||
voice_process = VoiceProcessing() | ||
# A remplacer avec la récupéation du model | ||
NLP = Nlp() | ||
|
||
### a enlever si l'entrainement n'est pas nécessaire pour vous | ||
# NLP.reset() | ||
# NLP.train(n_iter=400) | ||
### | ||
|
||
NLP.test() | ||
|
||
try: | ||
# Usecase: handling from a microphone | ||
# resultFromVoice = voice_process.from_audio() | ||
|
||
# Usecase: handling from an audiofile | ||
# resultFromVoice = voice_process.from_file(pathfile="oss117.mp4") | ||
|
||
# start, end = NLP.predict(resultFromVoice) | ||
# print("Trajet", start, " - ", end) | ||
pass | ||
except sr.RequestError: | ||
print("Connection problem, please try again later") | ||
return 1 | ||
except sr.UnknownValueError: | ||
print("Unintelligible text, please provide a new record ") | ||
return 1 | ||
except Exception as identifier: | ||
print(identifier) | ||
|
||
if __name__ == "__main__": | ||
# Reset NLP by hand if you want a MAJ on it before pushing repo into production (heroku) | ||
resetNlp() | ||
|
Oops, something went wrong.