Notice: file_put_contents(): Write of 20219 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50 [PYTHON:TODAY]@python2day P.6426
🔊 Создаём голосового помощника за несколько строк кода!
Скучно читать длинные PDF-документы? Python поможет. С помощью библиотеки pyttsx3 и PyPDF2 можно легко превратить любой PDF в аудиокнигу, которую ваш ПК будет зачитывать вслух.
🛠 Установка:
pip install pyttsx3 PyPDF2
import pyttsx3 from PyPDF2 import PdfReader from typing import Optional
def read_pdf_aloud(file_path: str, voice_id: Optional[int] = None, rate: int = 150) -> None: try: with open(file_path, 'rb') as file: pdf = PdfReader(file) speaker = pyttsx3.init() if voice_id is not None: voices = speaker.getProperty('voices') speaker.setProperty('voice', voices[voice_id].id) speaker.setProperty('rate', rate)
for i, page in enumerate(pdf.pages): text = page.extract_text() if text: print(f"\n📖 Чтение страницы {i+1}:\n{text[:200]}...\n") speaker.say(text) speaker.runAndWait()
speaker.stop() except Exception as e: print(f"Ошибка: {e}")
if __name__ == "__main__": read_pdf_aloud("your_file.pdf", voice_id=0)
👨💻Что делает код: ➡️ Открывает PDF-файл. ➡️ Проходит по всем страницам. ➡️ Извлекает текст. ➡️ Озвучивает содержимое с помощью встроенного синтезатора речи (работает офлайн!).
🔥Где пригодится: 💬 Для озвучки книг и лекций 💬 Быстрый просмотр текстов «на слух» 💬 Автоматизация чтения инструкций, мануалов и т.д.
🔊 Создаём голосового помощника за несколько строк кода!
Скучно читать длинные PDF-документы? Python поможет. С помощью библиотеки pyttsx3 и PyPDF2 можно легко превратить любой PDF в аудиокнигу, которую ваш ПК будет зачитывать вслух.
🛠 Установка:
pip install pyttsx3 PyPDF2
import pyttsx3 from PyPDF2 import PdfReader from typing import Optional
def read_pdf_aloud(file_path: str, voice_id: Optional[int] = None, rate: int = 150) -> None: try: with open(file_path, 'rb') as file: pdf = PdfReader(file) speaker = pyttsx3.init() if voice_id is not None: voices = speaker.getProperty('voices') speaker.setProperty('voice', voices[voice_id].id) speaker.setProperty('rate', rate)
for i, page in enumerate(pdf.pages): text = page.extract_text() if text: print(f"\n📖 Чтение страницы {i+1}:\n{text[:200]}...\n") speaker.say(text) speaker.runAndWait()
speaker.stop() except Exception as e: print(f"Ошибка: {e}")
if __name__ == "__main__": read_pdf_aloud("your_file.pdf", voice_id=0)
👨💻Что делает код: ➡️ Открывает PDF-файл. ➡️ Проходит по всем страницам. ➡️ Извлекает текст. ➡️ Озвучивает содержимое с помощью встроенного синтезатора речи (работает офлайн!).
🔥Где пригодится: 💬 Для озвучки книг и лекций 💬 Быстрый просмотр текстов «на слух» 💬 Автоматизация чтения инструкций, мануалов и т.д.
The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” Deputy District Judge Peter Hui sentenced computer technician Ng Man-ho on Thursday, a month after the 27-year-old, who ran a Telegram group called SUCK Channel, was found guilty of seven charges of conspiring to incite others to commit illegal acts during the 2019 extradition bill protests and subsequent months. Today, we will address Telegram channels and how to use them for maximum benefit. Telegram offers a powerful toolset that allows businesses to create and manage channels, groups, and bots to broadcast messages, engage in conversations, and offer reliable customer support via bots. To edit your name or bio, click the Menu icon and select “Manage Channel.”
from us