Exemple #1
0
    def text_to_speech(self,
                       text: str,
                       slow: bool = False,
                       use_cache: bool = True) -> str:
        # TODO: Allow various settings to be changed via config option
        from espeakng import ESpeakNG

        file_path = self._get_cache_file_path(text=text, use_cache=use_cache)

        if self._is_valid_cached_file(file_path=file_path,
                                      use_cache=use_cache):
            LOG.debug("Using existing cached file: %s" % (file_path))
            return file_path

        LOG.trace('Performing TTS on text "%s" and saving result to %s' %
                  (text, file_path))

        esng = ESpeakNG()
        esng.voice = "en-us"
        esng.pitch = 32
        esng.pitch = 32

        if slow:
            esng.speed = 80
        else:
            esng.speed = 150

        wave_data = esng.synth_wav(text)

        with open(file_path, "wb") as fp:
            fp.write(wave_data)

        return file_path
    def text_to_speech(self, text, voice='en-us', bit_rate=8000):
        speak = ESpeakNG(volume=200)
        speak.voice = voice

        wav_data = speak.synth_wav(text)
        self._tmp_in_file.seek(0)
        self._tmp_in_file.write(wav_data)

        self._convert(bit_rate)
Exemple #3
0
    def test_one(self):
        esng = ESpeakNG()
        esng.voice = 'en'
        #esng.speed = 10
        #esng.pitch = 50
        path = "/home/pi/tektrain-robot-sw/wav_sounds/test.wav"
        esng._espeak_exe(["Test now", "-w", path], sync=True)
        #print(audio)

        speak = Speaker()
        speak.write("test.wav", file_flag=True, volume=55)
Exemple #4
0
from espeakng import ESpeakNG


words = {
    "carrot": "морковь",
    "tomato": "помидор",
    "cucumber": "огурец",
    "watermelon": "арбуз",
    "fish": "рыба",
    "bread": "хлеб",
    "tumbler": "неваляшка",
    "car": "машина",
    "tree": "дерево",
    "ship": "корабль",
    "airplane": "самолет",
    "satellite": "спутник",
    "moon": "луна",
    "sun": "солнце",
    "cosmonaut": "космонавт",
}

engine = ESpeakNG()
engine.speed = 100
engine.pitch = 32
engine.voice = 'russian'

engine.say('Привет! Меня зовут Рома. Я очень рад вас видеть!', sync=True)
engine.voice = 'english'
engine.say('Hello! My name is Roma. I am glad to see you!', sync=True)

def say():
    esng = ESpeakNG()
    esng.voice = "german"
    with open('D:/abc.txt', mode='r') as files:
        p = files.read(500)
    esng.say("hello world")
Exemple #6
0
import sys, re, time, pyperclip
from espeakng import ESpeakNG
esng = ESpeakNG()
esng.voice = 'fr'


# Handles text formatting options
class color:
    PURPLE = '\033[95m'
    CYAN = '\033[96m'
    DARKCYAN = '\033[36m'
    BLUE = '\033[94m'
    GREEN = '\033[92m'
    YELLOW = '\033[93m'
    RED = '\033[91m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'
    END = '\033[0m'


def transcribe(chars):
    '''
    Transcribe each chunk of text to IPA
    Remove redundant IPA characters from transcription
    '''
    # (en) and (fr) appears in output of certain words, such as "weekend"
    redundant_regex = r'[ːˈˌ-]|\(en\)|\(fr\)'
    ipa = esng.g2p(chars, ipa=True)
    ipa = re.sub(redundant_regex, '', ipa)
    return ipa
Exemple #7
0
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.webnotifications.enabled", False)
profile.set_preference("general.useragent.override", "Mozilla/5.0")
profile.update_preferences()
browser = webdriver.Firefox(firefox_profile=profile,
                            executable_path=gecko_path)
url = "http://localhost:" + str(PORT) + "/html"
browser.get(url)
#for debug no fullscreen
if (not debug):
    pyautogui.press('f11')

##say hella
time.sleep(5)
esng = ESpeakNG()
esng.voice = "slovak"
#speaking move
browser.execute_script("return move();")
esng.say("Ahoj Olívia. Moje meno je Matúš.")
time.sleep(5)
browser.execute_script("return move();")
esng.say("Chceš sa so mnou hrať?")

##listen
r = sr.Recognizer()
with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source, duration=0.2)
    audio = r.listen(source)
    try:
        print("You said: " + r.recognize_google(audio, language="sk-SK"))
        browser.execute_script("return move();")
Exemple #8
0
#!/usr/bin/python3

#pip install py-espeak-ng espeak-ng

from espeakng import ESpeakNG

esng = ESpeakNG()
esng.voice = "english"
esng.say("Hello World!")

esng.voice = "slovak"
esng.say("Test 123")
#esng.say("Hallo Welt!")
Exemple #9
0
import snowboydecoder
import sys
import signal
import requests
from time import sleep
from espeakng import ESpeakNG
esng = ESpeakNG()
esng.voice = 'korean'
interrupted = False
is_quit = False


def executeCmd(cmd):
    global interrupted
    global esng
    print("Command executed -", cmd)
    try:
        if cmd == "Abort":
            requests.get("http://127.0.0.1:8088/stop?key=r0bogram")
            snowboydecoder.play_audio_file(snowboydecoder.DETECT_DONG)
            interrupted = True
        elif cmd == "Forward":
            requests.get("http://127.0.0.1:8088/forward?key=r0bogram")
            snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
        elif cmd == "Backward":
            requests.get("http://127.0.0.1:8088/backward?key=r0bogram")
            snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
        elif cmd == "Left":
            requests.get("http://127.0.0.1:8088/left?key=r0bogram")
            sleep(0.75)
            requests.get("http://127.0.0.1:8088/stop?key=r0bogram")
Exemple #10
0
        global RUNNING
        RUNNING = False


# TTS = pyttsx3.init()
# TTS.setProperty('voice', 'ru')  # Наш голос по умолчанию
# TTS.setProperty('rate', 150)    # Скорость в % (может быть > 100)
# TTS.setProperty('volume', 0.8)  # Громкость (значение от 0 до 1)
# print("pyttsx3 Voice names:")
# for voice in TTS.getProperty('voices'):
#     print(voice.name)
#     if voice.name == 'russian':
#         TTS.setProperty('voice', voice.id)

TTS = ESpeakNG()
TTS.speed = 150
TTS.voice = 'russian'
# pprint(TTS.voices)
# TTS.gender = 1

LISTENER = threading.Thread(target=listen_forever)
LISTENER.start()

CAPTURE_THREAD = threading.Thread(target=grab, args=(0, QUEUE, 200, 200))

APPLICATION = QtWidgets.QApplication(sys.argv)
WINDOW = MyWindowClass(None)
WINDOW.setWindowTitle('facerec')
WINDOW.show()
APPLICATION.exec_()
    description="GridTracker Call Roster Alerts",
    formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-d", "--debug", action="store_true",
                    help="Extra debugging to stderr")
parser.add_argument("-m", "--mute", action="store_true",
                    help="Log to stdout but don't do voice alerts")
parser.add_argument("-i", "--input", type=str, default="cr-alert.json",
                    help="Input .json file")
parser.add_argument("-l", "--lotw", type=int, default=0,
                    help="LOTW user active in last n days")
args = parser.parse_args()

logging.basicConfig(level=(logging.DEBUG if args.debug else logging.INFO))

esng = ESpeakNG()
esng.voice = "en-us"

pl = inflect.engine()

NOW = datetime.now(tz=None)

# LOTW callsigns as processed by GridTracker are in a .json file indexed
# by callsign and carrying the last upload date (in days since the epoch).
LOTW_CALLSIGNS = "../data/lotw-ts-callsigns.json"
LOTW_EPOCH = datetime(1970, 1, 1)
LOTW_CUTOFF = NOW - timedelta(days=args.lotw)
lotw_callsigns = {}
if args.lotw:
    lotw_callsigns = json.load(open(LOTW_CALLSIGNS))

Exemple #12
0

def next_color():
    return [int(x * 255) for x in colorsys.hls_to_rgb(random.random(), 0.6, 1)]


def speak(n):
    speech.say(str(n), sync=True)


pygame.init()
size = width, height = 720, 360
black = 0, 0, 0
white = 255, 255, 255
speech = ESpeakNG()
speech.voice = 'fr-be'
speech.speed = 120
speech.pitch = 75

screen = pygame.display.set_mode(size)
pygame.display.toggle_fullscreen()
pygame.display.set_caption("Numbers game")
font = pygame.font.SysFont('liberationsans', 256, True, False)
n = next_number()
color = next_color()

while True:
    played = False
    for event in pygame.event.get():
        if played:
            continue
Exemple #13
0
# encoding: utf-8
from espeakng import ESpeakNG

stops = ["a", "the", "and", "or", "of", "an"]
esng = ESpeakNG()
esng.voice = 'en-gb-x-rp'


def __get_tokens(title):
    tokens = title.lower().split(" ")
    tokens_to_test = []
    for token in tokens:
        if token not in stops:
            tokens_to_test.append(token)
    return tokens_to_test


def allitieration(title):
    tokens_to_test = __get_tokens(title)
    start_sounds = []
    for token in tokens_to_test:
        pronOUnciation = esng.g2p(token, ipa=2)
        start_sounds.append(pronOUnciation[0])
    print
    start_sounds

    n_of_alliterating = 0
    n_of_non_alliterating = 0
    for sound in start_sounds:
        n = start_sounds.count(sound)
        if n == 1: