Commit 5972248a authored by SupunGurusinghe's avatar SupunGurusinghe

Add new features

parent 70eacf1f
......@@ -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,67 +6,99 @@
<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="row">
<div class="col-md-6">
<form id="inputForm" enctype="multipart/form-data">
<div class="form-group">
<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">
<label class="custom-file-label" for="audioInput">Choose File</label>
</div>
<div class="container mt-5">
<div class="row">
<div class="col-md-6">
<form id="inputForm" enctype="multipart/form-data">
<div class="form-group">
<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">
<label class="custom-file-label" for="audioInput">Choose File</label>
</div>
<button type="submit" class="btn btn-primary">Process</button>
</form>
</div>
<div class="col-md-6">
</div>
<div class="form-group">
<label for="processedResult">Processed Result:</label>
<textarea class="form-control" id="processedResult" rows="5" readonly></textarea>
<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 id="copyButton" class="btn btn-secondary">Copy</button>
<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">
<div class="form-group">
<label for="processedResult">Processed Result:</label>
<textarea class="form-control" id="processedResult" rows="5" readonly></textarea>
</div>
<button id="copyButton" class="btn btn-secondary">Copy</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
$('#inputForm').submit(function (event) {
event.preventDefault();
var inputText = $('#inputText').val();
var audioInput = $('#audioInput')[0].files[0]; // Get the selected audio file
<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);
}
});
var formData = new FormData();
formData.append('input_text', inputText);
formData.append('audio_input', audioInput);
$('#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');
$.ajax({
type: 'POST',
url: '/process',
data: formData,
contentType: false,
processData: false,
success: function (response) {
$('#processedResult').val(response.processed_result);
}
});
});
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);
$('#copyButton').click(function () {
var copyText = $('#processedResult');
copyText.select();
document.execCommand('copy');
$.ajax({
type: 'POST',
url: '/process',
data: formData,
contentType: false,
processData: false,
success: function (response) {
$('#processedResult').val(response.processed_result);
}
});
});
// Display selected file name in the "Choose File" input field
$('#audioInput').change(function() {
var fileName = $(this).val().split('\\').pop();
$(this).siblings('.custom-file-label').addClass('selected').html(fileName);
});
$('#copyButton').click(function () {
var copyText = $('#processedResult');
copyText.select();
document.execCommand('copy');
});
// Display selected file name in the "Choose File" input field
$('#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