【问题标题】:How can I web-scrape real time captions from google meet, Using python如何使用 python 从 google meet 中抓取实时字幕
【发布时间】:2021-12-29 16:15:50
【问题描述】:

我想使用 python 从 google meet 中提取实时字幕。 我尝试了很多搜索,发现了一些不是开源的扩展,如果是,它们不是使用 python 构建的。 这是一个严重的问题,任何帮助将不胜感激。

【问题讨论】:

    标签: python google-chrome web web-scraping


    【解决方案1】:

    我建议您使用 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 很困难,所以安装时要小心。

    【讨论】:

    • 始终将代码、数据和完整的错误消息作为文本(不是屏幕截图,不是链接)放在有问题的地方(不在评论中)。它将更具可读性,更多人会看到它 - 因此更多人可以帮助您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-12
    • 2020-05-22
    • 1970-01-01
    相关资源
    最近更新 更多