Created
November 26, 2023 07:08
-
-
Save MayamaTakeshi/91a81bdf957be4a6f5db69f8f8d0d913 to your computer and use it in GitHub Desktop.
Speak japanese text copied to clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import pyperclip | |
import pyopenjtalk | |
import numpy as np | |
import sounddevice as sd | |
# Get initial clipboard content | |
previous_content = "" | |
while True: | |
# Get current clipboard content | |
current_content = pyperclip.paste() | |
# Check if clipboard content has changed | |
if current_content != previous_content: | |
print(f"{current_content}") | |
x, sr = pyopenjtalk.tts(f"{current_content}") | |
# Play the audio | |
sd.play(x.astype(np.int16), samplerate=sr) | |
sd.wait() | |
# Update previous content to current content | |
previous_content = current_content | |
time.sleep(0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment