def bluez_init():
    global bus
    global manager
    global adapter
    global esng
    global bluetooth_active
    global bt_devices

    bus = pydbus.SystemBus()
    if bus is None:
        logging.debug("Systembus not received")
        return False
    try:
        manager = bus.get(BLUEZ_SERVICE, '/')
        adapter = bus.get(BLUEZ_SERVICE, ADAPTER_PATH)
    except (KeyError, TypeError):
        logging.debug("Bluetooth: BLUEZ-SERVICE not initialised")
        return False
    bluetooth_active = True
    connected_devices()  # check if already devices are connected
    if esng is None:
        esng = ESpeakNG(voice='en-us', pitch=30, speed=175)
        if esng is None:
            logging.info("Bluetooth: espeak-ng not initialized")
            return True
        logging.info("Bluetooth: espeak-ng successfully initialized.")
    esng.say("Stratux Radar connected")
    print("SPEAK: Stratux Radar connected")
    return True
Beispiel #2
0
def direHeureMin(t):
    esng = ESpeakNG(voice='fr')
    if t.tm_hour == 12:
        s = 'midi'
    else:
        s = str(t.tm_hour) + ' heure'
    esng.say(u'Il est : ' + s + ' ' + str(t.tm_min), sync=True)
Beispiel #3
0
class SayIt():
    def __init__(self):
        self._espeak = ESpeakNG(voice='en-gb-x-gbclan')
        self._googleTTS = GoogleTTS()
        self._espeak.volume = 40
        rospy.init_node('sayit')
        self._sub = rospy.Subscriber('sayit/text', String, self.on_sayit_text)
        self._talkingPub = rospy.Publisher('sayit/talking',
                                           Bool,
                                           queue_size=10)
        self._service = rospy.Service('sayit', SpeechCommand,
                                      self.on_service_call)
        self._queue = Queue()

    def on_sayit_text(self, msg):
        text = msg.data
        rospy.loginfo('Request to say: ' + text)
        self._queue.put([text, None])

    def on_service_call(self, req):
        if req.command == 'say':
            responseQueue = Queue()
            self._queue.put([req.detail, responseQueue])
            response = responseQueue.get()
            return (response)
        else:
            return ('invalid')

    def run(self):
        while not rospy.is_shutdown():
            try:
                while not self._queue.empty():
                    # don't let requests accumulate
                    while self._queue.qsize() > 2:
                        text, responseQueue = self._queue.get()
                        if responseQueue:
                            responseQueue.put('skipped')

                    text, responseQueue = self._queue.get()
                    rospy.loginfo('Saying:' + text)
                    self._talkingPub.publish(True)
                    if ENGINE == 'google':
                        self._googleTTS.say(text)
                    else:
                        self._espeak.say(text, sync=True)
                    self._talkingPub.publish(False)
                    if responseQueue:
                        responseQueue.put('done')
                    rospy.loginfo('Done saying it')
            except:
                rospy.logerr_once(traceback.format_exc())

            rospy.sleep(PERIOD)
def speak(text):
    global esng

    if bluetooth_active and bt_devices > 0:
        if esng is None:  # first initialization failed
            esng = ESpeakNG(voice='en-us', pitch=30, speed=175)
            if esng is None:
                logging.info("Bluetooth: espeak-ng not initialized")
                return
            logging.info("Bluetooth: espeak-ng successfully initialized.")
        esng.say(text)
        logging.debug("Bluetooth speak: " + text)
Beispiel #5
0
    def test_say_unkown_voice(self):

        esng = ESpeakNG(voice='unknown-voice')
        esng.pitch = 32
        esng.speed = 150
        res = esng.say('Hello World!', sync=True)

        self.assertNotEqual(res, [])
Beispiel #6
0
    def test_say_en(self):

        esng = ESpeakNG(voice='english-us')
        esng.pitch = 32
        esng.speed = 150
        res = esng.say('Hello World!', sync=True)

        self.assertEqual(res, [])
Beispiel #7
0
def direHeure(t):
    esng = ESpeakNG(voice='fr')

    s = 'Nous sommes le ' + jour[t.tm_wday]

    if t.tm_mday == 1:
        s = s + ' premier'
    else:
        s = s + ' ' + str(t.tm_mday)
        
    s = s + ' ' + mois[t.tm_mon - 1] + '. ' + str(t.tm_year)

    if t.tm_hour == 12:
        s = s + 'Il est midi.'
    else:
        s = s + 'Il est : ' + str(t.tm_hour) + ' heure.'
    esng.say(s, sync=True)
Beispiel #8
0
class eSpeakModule(abstract.AbstractModule):
    """An eSpeak module using Microsoft Azure."""
    @staticmethod
    def name():
        return "eSpeak module"

    @staticmethod
    def description():
        return "eSpeak module"

    @staticmethod
    def input_ius():
        return [TextIU]

    def process_iu(self, input_iu):
        self.queue.clear()  # drop frames, if still waiting
        self.queue.append(input_iu)
        return None

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.queue = deque()
        self.esp = ESpeakNG()
        self.iasr = IncrementalizeASRModule()

    def run_detector(self):
        self.esp.voice = 'en-us'
        while True:

            if len(self.queue) == 0:
                time.sleep(0.5)
                continue

            input_iu = self.queue.popleft()
            text = self.iasr.process_iu(input_iu)
            if text.get_text()[0].isupper():
                self.esp.say(text.get_text(), sync=True)
                print(text.get_text())
            else:
                continue

    def setup(self):

        t = threading.Thread(target=self.run_detector)
        t.start()
Beispiel #9
0
def direTout():
    esng = ESpeakNG(voice='fr')

    esng.say('Bonjour.', sync=True)

    t = time.localtime()
    s = 'Nous sommes le '
    s = s + jour[t.tm_wday]

    if t.tm_mday == 1:
        s = s + ' premier'
    else:
        s = s + ' ' + str(t.tm_mday)
        
    s = s + ' ' + mois[t.tm_mon - 1]
    s = s + ' ' + str(t.tm_year)

    esng.say(s + '.', sync=True)

    s = 'Il est : '
    s = s + str(t.tm_hour) + ' heure'
    s = s + ' ' + str(t.tm_min) + ' et'
    s = s + ' ' + str(t.tm_sec) + ' seconde'

    esng.say(s + '.', sync=True)
        for i in range(num_pixels):
            pixel_index = (i * 256 // num_pixels) + j
            pixels[i] = wheel(pixel_index & 255)
        pixels.show()
        time.sleep(wait)
    
#sing "we wish you" while driving forward and turn leds red
forward()

pixels.fill((255, 0, 0)) 
pixels.show()
esng.pitch = 50
esng.speed = 130

#bot.drive(102, 32768)
esng.say("we")
sound(72, 1) #C

time.sleep(1)
#bot.stop()

pixels.fill((0, 255, 0)) 
pixels.show()
esng.pitch = 70
esng.say("wish")
sound(77, 1) #F

time.sleep(1)

pixels.fill((255, 0, 0)) 
pixels.show()
Beispiel #11
0
from time import sleep
from urllib.request import urlopen
from sys import exit
from espeakng import ESpeakNG
def internet_on():
    try:
        urlopen('http://216.58.192.142', timeout=1)
        return True
    except Exception as e:
        print(e)
        return False

esng = ESpeakNG()
esng.voice = 'korean'
esng.say("시스템 초기화 중입니다. 약 이십초 정도 걸립니다.")
i = 0
while i<20:
    print('Waiting for WIFI(',i+1,"s/20s)", sep='', end='\r')
    sleep(1)
    i += 1
try:
    if internet_on():
        from actions import say
        print("Loading online script...")
        say("인공지능 서버와 연결중입니다")
        from online import main
    else:
        esng.say("인공지능 서버와 연결할 수 없습니다. 오프라인 모드로 전환합니다.")
        print("Loading offline script...")
        from offline import main
except Exception as e:
Beispiel #12
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!")
Beispiel #13
0
# set_voice_and_say.py
import pyttsx3
tts = pyttsx3.init()
voices = tts.getProperty('voices')
tts.setProperty('voice', 'ru')
tts.say('Привет! Меня зовут Рома. Я очень рад вас видеть!')
tts.runAndWait()

from espeakng import ESpeakNG
engine = ESpeakNG()
engine.voice = 'english'
engine.speed = 150
engine.say(
    "I'd like to be under the sea. In an octopus's garden, in the shade!",
    sync=True)
engine.speed = 100
engine.pitch = 32
engine.voice = 'russian'
engine.say('Привет! Меня зовут Рома. Я очень рад вас видеть!', 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")
Beispiel #15
0
    output = ''
    for chars in split_text:
        if chars not in punctuations:
            chars = transcribe(chars)
            output += chars
        elif chars == '\n':
            output += chars
        elif chars in ':;!?«»\/':
            output += (' ' + chars + ' ')
        else:
            output += (chars + ' ')
    output = f'[{output.strip(". ")}]'
    # Copy transcribed IPA to clipboard
    pyperclip.copy(output)
    # Print transcribed IPA to terminal
    print(output)


text = sys.argv[1]
# Print input text in bold
print(color.BOLD + text + color.END, '\n')
# Print transcription in normal font
print_transcription(text)
# Pause for 1 second
time.sleep(1)
# Read text aloud
try:
    esng.say(text, sync=True)
except KeyboardInterrupt:
    pass
Beispiel #16
0
    def test_say_de(self):

        esng = ESpeakNG(voice='german')
        esng.pitch = 32
        esng.speed = 150
        esng.say('Wie geht es Dir?', sync=True)
Beispiel #17
0
#!/usr/bin/env python3
from espeakng import ESpeakNG
from num2words import num2words

esng = ESpeakNG()

print("Get ready")
esng.say('Hello World!')
esng.say(f"The secret number is {num2words(42)}")
print("Did it work?")
Beispiel #18
0
import wx  #for dynamic gui
import wikipedia  #search
import wolframalpha  #search
from espeakng import ESpeakNG

#ESpeakNG.synth_wav("Welcome")
#espeak.synth("Welcome"

ESpeakNG.say("Hello")


class MyFrame(wx.Frame):  #GUI Building
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          pos=wx.DefaultPosition,
                          size=wx.Size(450, 100),
                          style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION
                          | wx.CLOSE_BOX | wx.CLIP_CHILDREN,
                          title="PyAssistant")

        panel = wx.Panel(self)
        my_sizer = wx.BoxSizer(wx.VERTICAL)
        lbl = wx.StaticText(
            panel, label="Hello I am your Geanie. How may I help you?")
        my_sizer.Add(lbl, 0, wx.ALL, 5)
        self.txt = wx.TextCtrl(panel,
                               style=wx.TE_PROCESS_ENTER,
                               size=(400, 30))
        self.txt.SetFocus()
        self.txt.Bind(wx.EVT_TEXT_ENTER, self.OnEnter)
def init(obj):
    logging.debug("Commande d'initialisation du module.")
    esng = ESpeakNG(voice='fr', speed=150)
    s = 'Bienvenue a la mediatheque Marie Curie de Saint-Michel ! '
    esng.say(s, sync=True)
def parler(obj):
    logging.debug("Commande PARLER.")
    esng = ESpeakNG(voice='fr', speed=150, volume=10, pitch=90)
    esng.say(obj['phrase'], sync=True)
Beispiel #21
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();")
        esng.say("Dobre")
    except sr.UnknownValueError:
        print("No audio")
Beispiel #22
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)

Beispiel #23
0
from espeakng import ESpeakNG
esng = ESpeakNG()
esng.say('Hello World!')