Text from clipboard to audio

Another tool to hear the audio out of text capturing it with copy (control + c) keys combination and then pressing a button on a gui made with tkinter. Have fun. Github repository.

import win32clipboard
from gtts import gTTS
import time
import tkinter as tk
import os


def create_mp3(text, lang="en"):
    s = gTTS(text, lang=lang)
    print("Wait a second...")
    time.sleep(5)
    s.save(f"text.mp3")
    os.system("text.mp3")

def clip():
	win32clipboard.OpenClipboard()
	data = win32clipboard.GetClipboardData()
	win32clipboard.CloseClipboard()
	create_mp3(data)

root = tk.Tk()
root.title("Select the text, press crtl + c then press the button")
root.geometry("400x200")
but = tk.Button(root, text="Get audio from clipboard", command=clip, width=20,height=10, bg="gold")
but.pack()


root.mainloop()

New features here

Pytextaudio – get text from image to audio


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.