【发布时间】:2021-12-29 16:15:50
【问题描述】:
我想使用 python 从 google meet 中提取实时字幕。 我尝试了很多搜索,发现了一些不是开源的扩展,如果是,它们不是使用 python 构建的。 这是一个严重的问题,任何帮助将不胜感激。
【问题讨论】:
标签: python google-chrome web web-scraping
我想使用 python 从 google meet 中提取实时字幕。 我尝试了很多搜索,发现了一些不是开源的扩展,如果是,它们不是使用 python 构建的。 这是一个严重的问题,任何帮助将不胜感激。
【问题讨论】:
标签: python google-chrome web web-scraping
我建议您使用 pytesseract 从图像中获取文本。然后您可以使用 PIL 进行屏幕截图。您可以在 while 循环中重复此操作。 截取屏幕截图后,您可以使用 PIL 再次将其裁剪为文本。
一些示例代码是:
from PIL import Image
from PIL import ImageGrab
import pytesseract
import time
Lines = [] #Will store text
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files(x86)\Tesseract-OCR\tesseract.exe" #Or wherever your tesseract exe is stored
i = 0
while(i < 10): #Loop until you want to stop
image = ImageGrab.grab() #Take screen shot
width, height = image.size #Get width and height
left = 0 #Variables for cropping
top = 0
right = width
bottom = height
image = image.crop((left,top,right,bottom)) #Crop image
image_to_text = pytesseract.image_to_string(image) #Get text from image
#append text to lines
if(len(Lines) > 0):
if(Lines[len(Lines)-1] != image_to_text):
Lines.append(image_to_text)
else:
Lines.append(image_to_text)
i+=1
print(str(Lines)) </code>
您可能需要一些稍微不同的代码,因为 Google Meet 上的字词会同时出现一个。
我发现安装 pytesseract 很困难,所以安装时要小心。
【讨论】: