import speech_recognition as sr
sinput = '/tmp/test.wav'
r = sr.Recognizer()
harvard = sr.AudioFile(sinput)
with harvard as source:
audio = r.record(source)
out = r.recognize_google(audio)
print (out)
def ocr(self):
global dtout
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
dtout = pytesseract.image_to_string(Image.open(fname), 'rus+eng+chi_tra+jpn')
self.ui.textOut.setText(dtout)
ls /sys/bus/usb/drivers/usb-storage/
hub/ snd-usb-audio/ usb/ usb-storage/ usbfs/ usbhid/ uvcvideo/
ls /sys/bus/usb/drivers/usb-storage/
1-1.6:1.0@ bind module@ new_id remove_id uevent unbind
ls -lh lh /sys/bus/usb/drivers/usb-storage/1-1.6\:1.0
lrwxrwxrwx 1 root root 0 апр 6 07:05 /sys/bus/usb/drivers/usb-storage/1-1.6:1.0 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6/1-1.6:1.0/
ls /sys/devices/pci0000\:00/0000\:00\:1a.0/usb1/1-1/1-1.6/
...idProduct ...idVendor ...serial
cat /sys/devices/pci0000\:00/0000\:00\:1a.0/usb1/1-1/1-1.6/serial
lsusb
... ID 0930:6544 Toshiba ...
grep 0930 /sys/bus/usb/devices/*/idVendor
/sys/bus/usb/devices/1-1.6/idVendor:0930
cat /sys/bus/usb/devices/1-1.6/serial
time nuitka3 ocrgui.py --clang
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import re
import sys
import warnings
import os
import time
from PIL import Image
import pytesseract
from PyQt5 import (QtCore, QtGui, uic, QtWidgets)
from PyQt5.QtWidgets import (QMainWindow, QTextEdit, QAction, QFileDialog, QApplication, QProgressBar)
from PyQt5.QtGui import QIcon, QPicture
from PyQt5.QtCore import *
import locale
locale.setlocale(locale.LC_ALL, 'ru_RU.utf8')
warnings.filterwarnings("ignore")
cwd = os.path.dirname(os.path.abspath(__file__))
print (cwd)
dtout = ''
filename = "ocr.ui"
filename = f"{cwd}/{filename}"
Form, Base = uic.loadUiType(filename)
class MyWindow(QtWidgets.QWidget, Form):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.ui = Form()
self.ui.setupUi(self)
self.ui.btnQuit.clicked.connect(QCoreApplication.instance().quit)
self.ui.btnQuit.setToolTip("Выход")
self.ui.btnConv.setToolTip("Распознать")
self.ui.showd.clicked.connect(self.getfiles)
self.ui.btnSave.clicked.connect(self.save_f)
self.ui.showd.setToolTip("Открывает изображение")
self.ui.mylabel_2.setText("Входное изображение")
self.ui.btnConv.clicked.connect(self.ocr)
self.ui.mylabel.setText(f" ")
def getfiles(self):
global fname
fname = QFileDialog.getOpenFileName(self, "Open PNG", f"{cwd}/", "PNG (*.png);;GIF (*.gif);;JPG (*.jpg *.jpe *.JPEG );;TIFF (*.tiff);;All (*)")[0]
if fname == '':
QFileDialog(self, quit())
with open(fname, 'rb') as data:
self.ui.mylabel_2.setScaledContents(True)
self.ui.mylabel.setText(f"Файл: {fname}")
self.ui.mylabel_2.setPixmap(QtGui.QPixmap(f"{fname}"))
print (f"\n{fname}")
global fout
fout = re.sub(r'\.png|\.PNG', '', fname)
fout = fout + '.txt'
def ocr(self):
global dtout
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
dtout = pytesseract.image_to_string(Image.open(fname), 'rus+eng+chi_tra+jpn')
self.ui.textOut.setText(dtout)
def save_f(self):
if dtout == '':
self.ui.mylabel.setText(f"Файл не распознан")
elif dtout != '':
out = self.ui.textOut.toPlainText()
with open(fout, 'w') as f_out:
f_out.write(out + "\n")
self.ui.mylabel.setText('Файл сохранен: ' + fout)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MyWindow()
pal = window.palette()
window.setFixedSize(656, 320)
window.setWindowTitle("Gui for tesseract")
window.setWindowIcon(QtGui.QIcon(f"{cwd}/fontmanager.png"))
window.show()
sys.exit(app.exec_())
'HTTP_X_REAL_IP'
'HTTP_CLIENT_IP'
<?php
$file="stat.log"; // файл для записи истории посещения сайта
$col_zap=500; // ограничиваем количество строк log-файла
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) // Определяем IP
{ $ip=$_SERVER['HTTP_CLIENT_IP']; }
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{ $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; }
else { $ip=$_SERVER['REMOTE_ADDR']; }
return $ip;
}
if (strstr($_SERVER['HTTP_USER_AGENT'], 'YandexBot')) {$bot='YandexBot';} //Выявляем поисковых ботов
elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'Googlebot')) {$bot='Googlebot';}
else { $bot=$_SERVER['HTTP_USER_AGENT']; }
$ip = getRealIpAddr();
$date = date("H:i:s d.m.Y"); // определяем дату и время события
$home = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; // определяем страницу сайта
$lines = file($file);
while(count($lines) > $col_zap) array_shift($lines);
$lines[] = $date."|".$bot."|".$ip."|".$home."|\r\n";
file_put_contents($file, $lines);
?>
The environment variable 'Path' seems to have some paths containing the '"' character. The existence of such a character is known to have caused the Python extension to not load. If the extension fails to load please modify your paths to remove this '"' character.
Переменная окружения 'Path', кажется, имеет несколько путей,
содержащих символ "" ". Известно, что существование такого символа
приводило к тому, что расширение Python не загружалось. Если
расширение не удается загрузить, измените пути, чтобы удалить это" "' характер."