READER code example
Example 1: text to speech
import pyttsx3
engine = pyttsx3.init()
engine.say("write here what you want to speak")
engine.runAndWait()
Example 2: text to speech
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
const playButton = document.getElementById('play-button')
const pauseButton = document.getElementById('pause-button')
const stopButton = document.getElementById('stop-button')
const textInput = document.getElementById('text')
const speedInput = document.getElementById('speed')
let currentCharacter
playButton.addEventListener('click', () => {
playText(textInput.value)
})
pauseButton.addEventListener('click', pauseText)
stopButton.addEventListener('click', stopText)
speedInput.addEventListener('input', () => {
stopText()
playText(utterance.text.substring(currentCharacter))
})
const utterance = new SpeechSynthesisUtterance()
utterance.addEventListener('end', () => {
textInput.disabled = false
})
utterance.addEventListener('boundary', e => {
currentCharacter = e.charIndex
})
function playText(text) {
if (speechSynthesis.paused && speechSynthesis.speaking) {
return speechSynthesis.resume()
}
if (speechSynthesis.speaking) return
utterance.text = text
utterance.rate = speedInput.value || 1
textInput.disabled = true
speechSynthesis.speak(utterance)
}
function pauseText() {
if (speechSynthesis.speaking) speechSynthesis.pause()
}
function stopText() {
speechSynthesis.resume()
speechSynthesis.cancel()
}
</script>
<style>
body {
width: 90%;
margin: 0 auto;
margin-top: 1rem;
}
#text {
width: 100%;
height: 50vh;
}
</style>
<script src="script.js" defer></script>
</head>
<body>
<textarea id="text"></textarea>
<label for="speed">Speed</label>
<input type="number" name="spee" id="speed" min=".5" max="3" step=".5" value="1">
<button id="play-button">Play</button>
<button id="pause-button">Pause</button>
<button id="stop-button">Stop</button>
</body>
</html>
Example 3: reader
public static void main(String[] args) throws IOException {
Stack stack = new Stack();
Queues queue = new Queues();
File stackfile = new File("stack.txt");
if (!stackfile.exists()) {
stackfile.createNewFile();
} else {
System.out.println("File is done");
}
FileReader r= new FileReader(stackfile);
BufferedReader reader = new BufferedReader(r);
String line = null;
Data data= new Data(); // this class have String name, surname and string number
int i=1;
while ((line=reader.readLine())!=null) {
{ if(line.trim().equals("#")){
stack.Push(data);
data=new Data();
i=1;
}
else{
if(i==1){
data.setNo(line);
}
else if(i==2){
data.setName(line);
}
else if(i==3){
data.setSurName(line);
}
i++;
}
}
}
stack.Push(data);
reader.close();
File queuefile = new File("queue.txt");
if (!queuefile.exists()) {
queuefile.createNewFile();
} else {
System.out.println("File is done");
}
BufferedReader read = null;
read = new BufferedReader(new FileReader(queuefile));
String lines = read.readLine();
while (lines != null) {
System.out.println("Read from queue: " + lines);
{ if(lines.trim().equals("#")){
queue.insert(data);
data=new Data();
i=1;
}
else{
if(i==1){
data.setNo(line);
}
else if(i==2){
data.setName(line);
}
else if(i==3){
data.setSurName(line);
}
i++;
}
}
}
queue.insert(data);
read.close();
}
}
Example 4: screen reader text
/* Text meant only for screen readers. */
.screen-reader-text {
border: 0;
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
word-wrap: normal !important;
}