Commit 75fb0dc8 authored by W.G.G.A. Supun Sameera's avatar W.G.G.A. Supun Sameera

Merge branch 'IT20146924' into 'master'

It20146924

See merge request !3
parents d38f7faf 604e8f67
......@@ -61,3 +61,5 @@ Thumbs.db
*.csv
*.txt
venv/
/venv/
import os
from flask import Flask, render_template, request, jsonify
from sinlingua.singlish.rulebased_transliterator import RuleBasedTransliterator
from sinlingua.sinhala_audio.audio_to_text import conversion
app = Flask(__name__)
......@@ -25,13 +29,22 @@ def index():
def process():
input_text = request.form.get('input_text')
audio_input = request.files.get('audio_input')
processed_result = None
if input_text:
obj = RuleBasedTransliterator()
# Perform text processing on input_text
processed_result = f"{input_text}" # Example text processing
out = obj.transliterator(text=input_text)
processed_result = f"{out}" # Example text processing
elif audio_input:
# Save the uploaded file to a specific directory
upload_dir = 'src'
os.makedirs(upload_dir, exist_ok=True)
audio_path = os.path.join(upload_dir, audio_input.filename)
audio_input.save(audio_path)
# Perform audio processing
processed_result = "Audio Collected"
out = conversion(path=audio_path)
processed_result = f"{out}"
return jsonify({'processed_result': processed_result})
......
This diff is collapsed.
{
"name": "sinlinguatoolkit",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"electron": "^26.0.0",
"electron-packager": "^17.1.2"
}
}
Flask==2.3.2
\ No newline at end of file
Flask==2.3.3
\ No newline at end of file
......@@ -6,7 +6,7 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
<div class="container mt-5">
<div class="row">
<div class="col-md-6">
<form id="inputForm" enctype="multipart/form-data">
......@@ -14,11 +14,28 @@
<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">
<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>
<div class="form-group">
<label>Checkboxes:</label>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkbox1" name="checkbox1">
<label class="form-check-label" for="checkbox1">Checkbox 1</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkbox2" name="checkbox2">
<label class="form-check-label" for="checkbox2">Checkbox 2</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="checkbox3" name="checkbox3">
<label class="form-check-label" for="checkbox3">Checkbox 3</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Process</button>
<button type="reset" class="btn btn-secondary">Reset</button>
</form>
</div>
<div class="col-md-6">
......@@ -29,19 +46,34 @@
<button id="copyButton" class="btn btn-secondary">Copy</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
// Disable checkbox2 if checkbox1 is checked
$('#checkbox1').change(function () {
if ($(this).is(':checked')) {
$('#checkbox2').prop('disabled', true);
} else {
$('#checkbox2').prop('disabled', false);
}
});
$('#inputForm').submit(function (event) {
event.preventDefault();
var inputText = $('#inputText').val();
var audioInput = $('#audioInput')[0].files[0]; // Get the selected audio file
var checkbox1 = $('#checkbox1').is(':checked');
var checkbox2 = $('#checkbox2').is(':checked');
var checkbox3 = $('#checkbox3').is(':checked');
var formData = new FormData();
formData.append('input_text', inputText);
formData.append('audio_input', audioInput);
formData.append('checkbox1', checkbox1);
formData.append('checkbox2', checkbox2);
formData.append('checkbox3', checkbox3);
$.ajax({
type: 'POST',
......@@ -62,11 +94,11 @@
});
// Display selected file name in the "Choose File" input field
$('#audioInput').change(function() {
$('#audioInput').change(function () {
var fileName = $(this).val().split('\\').pop();
$(this).siblings('.custom-file-label').addClass('selected').html(fileName);
});
});
</script>
</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