Skip to content

Instantly share code, notes, and snippets.

View lewoudar's full-sized avatar
🏠
Working from home

Kevin Tewouda lewoudar

🏠
Working from home
  • Paris
View GitHub Profile
@lewoudar
lewoudar / twitter_server_for_postponed_tweet_creation.py
Last active November 20, 2022 18:46
FastAPI server to to schedule tweet creation
# you will need to install the following libraries
# - FastAPI
# - tweepy (version 4.X)
# - twitter-text-parser
# - apscheduler (version 3.X)
import logging
import os
from datetime import datetime
from typing import Optional, List
@lewoudar
lewoudar / transcribe.py
Created June 22, 2024 11:55
Playing with the ctranslate2 backend
import os
import time
from dataclasses import dataclass, field
from pathlib import Path
from typing import Literal
from faster_whisper import WhisperModel
model_size = "large-v3"
# workaround if we have already installed openai whisper stuff via transformers
@lewoudar
lewoudar / extract_text_and_images_from_pdf.py
Last active August 12, 2024 19:36
Example usage of pdfminer to extract text and images from a PDF
from pdfminer.high_level import extract_text_to_fp
from pdfminer.layout import LAParams
def extract_text_from_pdf(input_filename: str, output_filename: str, output_images_dir: str | None = None) -> None:
with open(input_filename, 'rb') as input_file, open(output_filename, 'w', encoding='utf-8') as output_file:
extract_text_to_fp(input_file, output_file, output_dir=output_images_dir, laparams=LAParams())
extract_text_from_pdf(