Added clipboard functionality.
This commit is contained in:
parent
4607302e05
commit
77ad77831e
@ -3,10 +3,9 @@ Written by Storm Dragon
|
|||||||
released under the terms of the WTFPL http://wtfpl.net/
|
released under the terms of the WTFPL http://wtfpl.net/
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
sox
|
python-pygame
|
||||||
bash version 4 or greater
|
|
||||||
pygame
|
|
||||||
python-xdg
|
python-xdg
|
||||||
|
python-pyperclip
|
||||||
python-requests
|
python-requests
|
||||||
|
|
||||||
Playing
|
Playing
|
||||||
|
@ -9,6 +9,7 @@ from os.path import isfile, join
|
|||||||
from inspect import isfunction
|
from inspect import isfunction
|
||||||
from xdg import BaseDirectory
|
from xdg import BaseDirectory
|
||||||
import pygame
|
import pygame
|
||||||
|
import pyperclip
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
import speechd
|
import speechd
|
||||||
@ -90,7 +91,7 @@ def credits():
|
|||||||
|
|
||||||
def display_text(text):
|
def display_text(text):
|
||||||
i = 0
|
i = 0
|
||||||
text.insert(0, "Press space to read the whole text. Use up and down arrows to navigate the text line by line. Press enter or escape when you are done reading.")
|
text.insert(0, "Press space to read the whole text. Use up and down arrows to navigate the text line by line. Press c to copy the current line to the clipboard or t to copy the entire text. Press enter or escape when you are done reading.")
|
||||||
text.append("End of text.")
|
text.append("End of text.")
|
||||||
speak(text[i])
|
speak(text[i])
|
||||||
while True:
|
while True:
|
||||||
@ -103,6 +104,18 @@ def display_text(text):
|
|||||||
speak(''.join(text[1:]))
|
speak(''.join(text[1:]))
|
||||||
else:
|
else:
|
||||||
speak(text[i])
|
speak(text[i])
|
||||||
|
if event.key == pygame.K_c:
|
||||||
|
try:
|
||||||
|
pyperclip.copy(text[i])
|
||||||
|
speak("Copied " + text[i] + " to the clipboard.")
|
||||||
|
except:
|
||||||
|
speak("Failed to copy the text to the clipboard.")
|
||||||
|
if event.key == pygame.K_t:
|
||||||
|
try:
|
||||||
|
pyperclip.copy(''.join(text[1:-1]))
|
||||||
|
speak("Copied entire message to the clipboard.")
|
||||||
|
except:
|
||||||
|
speak("Failed to copy the text to the clipboard.")
|
||||||
event = pygame.event.clear()
|
event = pygame.event.clear()
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user