Commit 70eacf1f authored by SupunGurusinghe's avatar SupunGurusinghe

Added audio feature

parent e9b8d22f
......@@ -9,8 +9,14 @@ def index():
if request.method == 'POST':
input_text = request.form.get('input_text')
# Perform processing on input_text and set processed_result
processed_result = f"Processed: {input_text}" # Example processing
audio_input = request.files.get('audio_input')
if input_text:
# Perform text processing on input_text
processed_result = f"Processed: {input_text}" # Example text processing
elif audio_input:
# Perform audio processing
processed_result = "Audio Collected"
return render_template('index.html', processed_result=processed_result)
......@@ -18,8 +24,15 @@ def index():
@app.route('/process', methods=['POST'])
def process():
input_text = request.form.get('input_text')
# Perform processing on input_text and set processed_result
processed_result = f"{input_text}" # Example processing
audio_input = request.files.get('audio_input')
if input_text:
# Perform text processing on input_text
processed_result = f"{input_text}" # Example text processing
elif audio_input:
# Perform audio processing
processed_result = "Audio Collected"
return jsonify({'processed_result': processed_result})
......
......@@ -6,14 +6,17 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<webview src="http://localhost:5000" style="width: 100%; height: 100%;"></webview>
<div class="container mt-5">
<div class="row">
<div class="col-md-6">
<form id="inputForm">
<form id="inputForm" enctype="multipart/form-data">
<div class="form-group">
<label for="inputText">Enter Text:</label>
<textarea class="form-control" id="inputText" rows="5"></textarea>
<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>
<button type="submit" class="btn btn-primary">Process</button>
</form>
......@@ -34,10 +37,18 @@
$('#inputForm').submit(function (event) {
event.preventDefault();
var inputText = $('#inputText').val();
var audioInput = $('#audioInput')[0].files[0]; // Get the selected audio file
var formData = new FormData();
formData.append('input_text', inputText);
formData.append('audio_input', audioInput);
$.ajax({
type: 'POST',
url: '/process',
data: { input_text: inputText },
data: formData,
contentType: false,
processData: false,
success: function (response) {
$('#processedResult').val(response.processed_result);
}
......@@ -49,6 +60,12 @@
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>
</body>
......
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