Video summary
Bu videoda izleyiciye, bilgisayar ekranındaki görüntülerdeki yazıları okutma yeteneği kazandırılacak basit bir komut satırı yöntemi anlatılıyor. Sunucu, işlemin temel mantığını açıklamak için önce eSpeak adlı hafif ve kurulumu kolay bir metin-okuma uygulamasını örnek gösteriyor; ancak asıl odak noktası, ekran görüntüsü alıp bu görselden metni çıkarmaktır. Bu süreçte `scrot` yazılımı kullanılarak belirli bir alan seçilerek veya tüm monitörlerden görüntü alınarak dosya oluşturuluyor. Eğer aynı isimde bir dosya zaten varsa, komuta `-o` parametresi eklenerek bu durum aşılıyor ve yeni görüntü otomatik olarak üzerine yazdırılıyor.
Görselin metne dönüştürülmesi aşamasında ise `Tesseract` adlı optik karakter tanıma (OCR) aracı devreye giriyor. Komut satırı üzerinde yapılan işlemlerde, önceki komutun başarılı olup olmadığını kontrol eden `&&` operatörü kullanılarak zincirleme bir yapı kuruluyor. Tesseract'ın çalıştırılması sırasında oluşan gereksiz uyarı mesajlarını gizlemek için çıktı akışı `dev null` adresine yönlendiriliyor ve sadece temizlenmiş metin verisi elde ediliyor. Elde edilen bu ham metin, değişkenlere kaydedilerek daha sonra kullanılmak üzere saklanıyor veya doğrudan eSpeak'e gönderilerek sesli olarak dinlenebiliyor.
Sonuç olarak, tüm bu adımlar birleştirilerek `ocr_screen` adında tek satırlık ve oldukça pratik bir betik oluşturuluyor. Bu betik, ekranın seçilen bölgesini görüntüleyip metne çevirir, varsa uyarıları bastırır, metni ekrana yazar, sesli okutur ve kullanılan geçici dosyayı temizler. Sunucu, bu yöntemin farklı font tipleriyle test edildiğini ve karmaşık yazı tiplerinde zorlanabileceğini belirtse de genel olarak oldukça başarılı sonuçlar verdiğini vurguluyor. İzleyiciler için video açıklamasında yer alan linkten hem bu betiğin kendisi hem de ilgili notlar indirilebileceği belirtilerek, bilgisayar ekranındaki herhangi bir metnin kolayca seslendirilmesine olanak tanınan bir çözüm sunulmuş olur.
Read the full video transcript
Welcome to a video from Fields by Chris.
That's Chris with a K.
>> Welcome. I will be playing with eSpeak
today, but that's not really the the
point of the tutorial. eSpeak is just
It's not the best-sounding text-to-voice
application, but it's easy to install,
it's small, and I'm just using an
example, but you can use whatever
text-to-speech application you want.
What we're going to be doing today, I
actually have a script on my computer.
Let me type something. This is a test. I
have it set up so that I can highlight
and copy text, and then if I just hit my
super key, alt, and T, it will actually
test.
>> This is a test. I have it set up to take
that whatever's in my clipboard and read
it at double speed
using
another voice to speech that sounds
better. But I'm just using eSpeak in
this video, but that's simple. We
already have the text in clipboard, we
just have to pipe the clipboard to
whatever voice-to-text application or
text-to-voice application you want.
We're going to do something different
today. We're going to grab a screenshot
so you can grab text that's in an image
maybe on your screen and have it read to
you. So let's start. There's lots of
applications out there that can take
screenshots. We're going to look at
scrot. So scrot, and then we'll give it
a file. I'll say ocr.png,
and then it just took a screenshot and
saved it right here to this file. So let
me go ahead and open that, and you can
see there it is. It actually took
picture of all three of my screens cuz I
have three monitors
by default. So if I try to run that
again,
it's going to tell me that file already
exists. The way we can override that is
just by giving it {dash} o, and it'll
automatically override that file.
Another thing we can do is we can
actually choose a section of the screen
we want to select. So I can say {dash}
s. Now I run that, you can see my cursor
has changed. I can now draw a box around
part of the screen, and if I was to
open, which open is just a shortcut on
my machine to xdg-open,
but use whatever image viewer you use.
There you go. That's the new image right
there from the little section of the
screen that I selected.
So we've been able to take a screenshot
of a particular part of the screen we
want. What we can do now is we can take
that, and all my notes are going to be
in the link in the description. We can
run this command, and we can say,
"Okay."
Ampersand ampersand means that last
command was successful. For some reason
it didn't capture a screen uh shot, it's
not going to run the next command. Uh,
Tesseract is an application I've talked
about before that does OCR, optical
character recognition. It's going to
take that image and look for text in it.
We're going to say, "Run Tesseract
again." We believe the last command was
successful. We're going to run it on the
image we just collected, and we're going
to do just pipe it to standard output.
We run that.
And oh, right. I have to select a part
of the screen, so let me just grab some.
I'll just grab this part of the screen
here.
And it has converted that image to text.
We do get this. Every time it will tell
you estimated resolution of the image.
We don't want that, so we're going to
add to that. We're going to say, uh,
"two." And then we'll pipe that into,
uh, not pipe, but redirect that into dev
null. Uh, what this is going to do is so
any, um, warning messages or error
messages are going to be dumped to that,
so we're not going to see that. Again,
now I can grab part of the screen, and
it's going to now take the image that we
just took of the screen, and pipe the
screen the the text to the screen.
Let's take that, wrap it in quotes and
dollar signs. Now we're going to run
that command, and the output's going to
be a string. We're going to say, "Put
that in a variable called text."
So again, I'll grab part of the screen
here.
And now I can echo dollar sign text. We
can see what it got from that image, and
how it translated it into text. Of
course, we could always put that into
eSpeak.
I have this turned up so you can hear it
out of the speakers.
That did not work. Invalid option.
Dollar sign. Do I need to
put this in quotations?
Let's try this again. We're going to
grab part of the screen.
Give it to eSpeak.
>> Download effects.
>> There we go.
>> 1000 not to be on flash tmp slash
tutorial slash
That's great. Let's go ahead and put
that all into a script, which I actually
have done.
I have wrote this script. I called it
OCR screen. Let me back cat that out so
we can look at this. And I will put a
link to this in the description, but
again, it's just the lines we've done.
We're running that command, putting the
text into a text variable. I could uh
check to make sure there's actually
something in that variable. Like if it
doesn't detect any text, if it's empty,
it just exit. But it will echo out to
the to the shell what the text is, then
it will speak it, and then it will check
to see if that image file exists. If so,
it will remove it, just a little bit of
cleanup there at the end. So now, I can
run that OCR screen, and I can select
something like just this here.
Okay, let's try it with an actual image.
Now, normally I would set this up for a
keyboard shortcut. I don't have that set
up yet, so I'm just going to sleep for 2
seconds and then run that command. I'm
going to flip over to my web browser
here where I just grabbed a random
image. You can see my cursor has
changed. I can now select uh this image.
So, that's just a random image. I tried
this on a bunch of images. Obviously, if
your font gets really funky, it's going
to have trouble reading it. Uh but even
font like this, it did a great job. Uh
so yeah, there'll be a link in the
description to this script. Again, I'll
put it up on the screen here. Let's go
back cat.
Oh, got an extra dash in there. There we
go.
Uh and yeah, that's the whole thing
right there. You'll be able to download
it from the link. Uh and I will actually
put some notes to these It's only four
lines of code. I'll put that in the
description of the video as well. Uh and
I'm In this example again, I'm using
eSpeak. Uh
there's other text voice to yeah, text
to voice applications out there. eSpeak
is just the quickest, easiest, smallest
one to set up, but again, it sounds very
robotic. Uh and this tutorial isn't on
setting up the the voice-to-text
text-to-voice application. So, I hope
you found this useful. Check out the
links in the description of this video.
As always, I thank you for watching and
I hope that you have a great day.