Note that this tag is original input HTML, read Custom Template Tags. If you just want the db value, you should use the {{{dbvalue xxx}}} tag, see the docs on how to use it.
HI, i want to use it as orignal HTML , becuase i want to connect it with javascript as here:
function startDictation() {
// Check if the browser supports SpeechRecognition
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
// Set the language for recognition
recognition.lang = 'en-US'; // You can change this to your preferred language
recognition.interimResults = false; // Set to true if you want interim results
// Start the speech recognition
recognition.start();
// When speech is recognized
recognition.onresult = function(event) {
// Get the recognized text from the event
var transcript = event.results[0][0].transcript;
// Populate the text field with the recognized text
document.getElementById('cmnt').value = transcript; // Use value for <input>
};
// Handle errors
recognition.onerror = function(event) {
console.error('Speech recognition error detected: ' + event.error);
};
}
// Ensure the document is ready before binding events
$(document).ready(function() {
// Bind the startDictation function to a button click
$('#startButton').click(function() {
startDictation(); // Call the function when the button is clicked
});
});
Hi,
when i use php file : the code is working perfectly: here is the code:
<?php
// voice_note.php
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voice Note Example</title>
<script>
function startDictation() {
// Check if the browser supports SpeechRecognition
var recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
// Set the language for recognition
recognition.lang = 'en-US'; // You can change this to your preferred language
recognition.interimResults = false; // Set to true if you want interim results
// Start the speech recognition
recognition.start();
// When speech is recognized
recognition.onresult = function(event) {
// Get the recognized text from the event
var transcript = event.results[0][0].transcript;
// Populate the text field with the recognized text
document.getElementById('cmnt').value = transcript; // Use value for <input>
};
// Handle errors
recognition.onerror = function(event) {
console.error('Speech recognition error detected: ' + event.error);
};
}
document.addEventListener('DOMContentLoaded', function() {
// Any additional setup can go here
});
</script>
</head>
<body>
<table>
<tr>
<td><button type="button" onclick="startDictation()">Voice Note</button></td>
<td>Comments</td>
<td><textarea id="cmnt" ></textarea></td> <!-- This will be the text field -->
</tr>
</table>
</body>
</html>
and when i tray to put the code in my template as: