Is there a way to determine what word a screen reader such as NVDA is currently reading in real time? - nvda

Current reading word of a screen reader
Need to determine the time taken to read each word and frequency of navigation

Related

How can I get current microphone input level with C WinAPI?

Using Windows API, I want to implement something like following:
i.e. Getting current microphone input level.
I am not allowed to use external audio libraries, but I can use Windows libraries. So I tried using waveIn functions, but I do not know how to process audio input data in real time.
This is the method I am currently using:
Record for 100 milliseconds
Select highest value from the recorded data buffer
Repeat forever
But I think this is way too hacky, and not a recommended way. How can I do this properly?
Having built a tuning wizard for a very dated, but well known, A/V conferencing applicaiton, what you describe is nearly identical to what I did.
A few considerations:
Enqueue 5 to 10 of those 100ms buffers into the audio device via waveInAddBuffer. IIRC, when the waveIn queue goes empty, weird things happen. Then as the waveInProc callbacks occurs, search for the sample with the highest absolute value in the completed buffer as you describe. Then plot that onto your visualization. Requeue the completed buffers.
It might seem obvious to map the sample value as follows onto your visualization linearly.
For example, to plot a 16-bit sample
// convert sample magnitude from 0..32768 to 0..N
length = (sample * N) / 32768;
DrawLine(length);
But then when you speak into the microphone, that visualization won't seem as "active" or "vibrant".
But a better approach would be to give more strength to those lower energy samples. Easy way to do this is to replot along the μ-law curve (or use a table lookup).
length = (sample * N) / 32768;
length = log(1+length)/log(N);
length = max(length,N)
DrawLine(length);
You can tweak the above approach to whatever looks good.
Instead of computing the values yourself, you can rely on values from Windows. This is actually the values displayed in your screenshot from the Windows Settings.
See the following sample for the IAudioMeterInformation interface:
https://learn.microsoft.com/en-us/windows/win32/coreaudio/peak-meters.
It is made for the playback but you can use it for capture also.
Some remarks, if you open the IAudioMeterInformation for a microphone but no application opened a stream from this microphone, then the level will be 0.
It means that while you want to display your microphone peak meter, you will need to open a microphone stream, like you already did.
Also read the documentation about IAudioMeterInformation it may not be what you need as it is the peak value. It depends on what you want to do with it.

0xC00D4A44 MF_E_SINK_NO_SAMPLES_PROCESSED with MPEG 4 sink

I am running out of ideas on why I am getting this HRESULT.
I have a pipeline in Media Foundation. A file is loaded through the source resolver. I am using the media session.
Here is my general pipeline:
Source Reader -> Decoder -> Color Converter (to RGB24) -> Custom MFT -> Color Converter (To YUY2) -> H264 Encoder -> Mpeg 4 Sink
In my custom MFT I do some editing to the frames. One of the tasks of the MFT is to filter samples and drop the undesired ones.
This pipeline is used to trim video and output an MP4 file.
For example if the user wants to trim 3 seconds from the 10 second marker, my MFT will read the uncompressed sample time and discard it by asking for more samples. If a sample is in range, it will be passed to the next color converter. My MFT handles frames in RGB24, hence the reason for the initial color converter. The second color converter transforms the color space for the H264 encoder. I am using the High Profile Level 4.1 encoder.
The pipeline gets setup properly. All of the frames get passed to the sink and I have a wrapper for the MPEG4 sink. I see that the BeginFinalize and EndFinalize gets called.
However on some of my trim operations, the EndFinalize with spit out the MF_E_SINK_NO_SAMPLES_PROCESSED. I think it is random. It usually happens when a range not close to the beginning is selected.
It might be due to sample times. I am rebasing the sample times and duration.
For example, if the adjusted frame duration is 50ms (selected by user), I will grab the first acceptable sample (let's say 1500ms) and rebase it to 0. The next one will be 1550ms in my MFT and then set to 50ms and so on. So frame times are set in 50ms increments.
Is this approach correct? Could it be that the sink is not receiving enough samples to write the headers and finalize the file?
As mentioned, it work in some cases and it fails in most. I am running my code on Windows 10.
I tried to implement the same task using IMFMediaSession/IMFtopology, but had the same problems you faced. I think that IMFMediaSession either modifies the timestamps outside your MFT, or expects them not to be modified by your MFT.
So in order to make this work, I took the IMFSourceReader->IMFSinkWriter approach.
This way I could modify the timestmaps of the samples read from the reader and pass to the writer only those that fall into the given range.
Furthermore, you can take a look at the old MFCopy example. It does exactly the file trimming as you described it. You can download it from here: https://sourceforge.net/projects/mfnode/

Implement a keyboard buffer in C given a keyboard event

I have a C program that detects keyboard events, but I need to know the best technique to implement an input buffer and a simple getch function to retrieve the oldest character in the buffer.
One way is to use a circular buffer. You create a fixed sized array and have two indices, a read index and a write index. Each time a keyboard event fires, you place the value at the write index and increment. When the getch function is called, you read from the read index and increment it. If either index goes over the size of the array, it gets reset to the beginning.
If the read index and the write index are equal, there are no keys waiting. If the write index is just before the read index, the buffer is full and keyboard events need to be dropped.
If you don't want a "full" buffer it gets more complicated.

Java programming in files , random , GUI

I want to write a Java program that reads the data from a file and stores it in an array. And then generates a random array index and uses it to retrieve a random word from the array to display. Each time the user clicks Next button, the program chooses a new random word to be displayed. I'm trying to add buttons in frame but they won't appear on the JFrame. Following is the code I wrote:
okButton = new JButton ("OK");
Pane.add(okButton);
nextButton = new JButton ("Next");
Pane.add(nextButton);
When the user enters a right answer I want a JLabel to appear saying " Correct answer ". How do I make a JLabel Appear? and when the user closes the frame all the right answers show in a JTextArea.
Can you please help me?
Your question is too much cluttered and vague to me, so providing perfect answer is quite not possible. Following are some useful tips you can use to solve your problem.
read file which contains the word. See File operations in Java and
How to use FileChooser?
Tokenize file and create an array of words. You can use StringTokenizer class for this
Create a method to randomly word from the array. You can use Random class for this.
For the GUI part:
the buttons won't appear on the JFrame
Are you adding panel containing buttons to frame properly?
how do I make a JLabel Appear ?
Add that JLabel to panel/frame and repaint it.
when the user closes the frame all the right answers show in a
JTextArea
Save right answers in some other array (call it answerArray).
Add Window listener to frame to monitor closing of frame.
In close method create a JDialog containing JTextArea and loop over answerArray and append string to textArea. Finally display this new JDialog.

How to make a scroller on a micro-processor/-controller?

I would like to write a text scroller on a micro-processor with 4 5x7 displays in ANSI-C.
Does anyone know of example source code or anything that can help me get started?
Update
This is the user manual for the micro-processor board I have. On PDF page 17 is a picture of the board with the displays.
The code is written in an IDE called "zds2_Z8Encore493.exe" and then flashed to the micro-controller over serial port.
I would like the text to cascade from one to the next to the next column-by-column, so it is smooth.
There may be a better way, but I would store the text in a block of RAM, and in the routines that update the displays I would include a value to offset the starting point, possibly with a wrap-around to the start. The you store a counter which increments the "global" offset (scrolling).
You can then use string[offset + display-width + scroll_position] as the start pointer, but you need to detect the end and wrap round or just stop.

Resources