예제 #1
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)
예제 #2
0
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
예제 #3
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, [])
예제 #4
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, [])
예제 #5
0
    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)
예제 #6
0
    def test_g2p(self):
        esng = ESpeakNG(voice='english-us')

        for g, xs_t, ipa_t in G2P_TESTS:

            xs = esng.g2p(g)
            self.assertEqual(xs, xs_t)

            ipa = esng.g2p(g, ipa=2)
            self.assertEqual(ipa, ipa_t)
예제 #7
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)
예제 #8
0
    def test_synth_wav_xsampa(self):

        esng = ESpeakNG(voice='english-us')
        esng.pitch = 32
        esng.speed = 150
        wavs = esng.synth_wav("h@l'oU", fmt='xs')
        wav = wave.open(BytesIO(wavs))

        self.assertEqual(wav.getnchannels(), 1)
        self.assertEqual(wav.getframerate(), 22050)
        self.assertGreater(wav.getnframes(), 20000)
예제 #9
0
    def test_synth_wav(self):

        esng = ESpeakNG(voice='english-us')
        esng.pitch = 32
        esng.speed = 150
        wavs = esng.synth_wav('Hello World!')
        wav = wave.open(BytesIO(wavs))

        self.assertEqual(wav.getnchannels(), 1)
        self.assertEqual(wav.getframerate(), 22050)
        self.assertGreater(wav.getnframes(), 24000)
예제 #10
0
 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()
예제 #11
0
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)
예제 #12
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)
예제 #13
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)
예제 #14
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)
예제 #15
0
파일: eSpeak.py 프로젝트: bsu-slim/rr-sds
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()
예제 #16
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
예제 #17
0
    def __init__(
            self,
            host_tts='local',
            port_tts=8300,
            locale='en_US',
            engine='mary',
            voice='cmu-rms-hsmm',
            pitch=50,  # 0-99
            speed=175):  # approx. words per minute

        self._host_tts = host_tts
        self._port_tts = port_tts
        self._locale = locale
        self._engine = engine
        self._voice = voice
        self._pitch = pitch
        self._speed = speed

        if host_tts == 'local':
            self.player = PulsePlayer('Local TTS Client')
            self.espeak = ESpeakNG()
            self.marytts = MaryTTS()
            self.picotts = PicoTTS()
예제 #18
0
# Choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D18
# NeoPixels must be connected to D10, D12, D18 or D21 to work.
pixel_pin = board.D10

# The number of NeoPixels
num_pixels = 33

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
ORDER = neopixel.GRB
color = (255, 0, 0)


#sing we wish you a merry christmas and perform a dance
esng = ESpeakNG() #initialize singing voice
bot = roomba_pi.Robot() #initialize roomba
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.1, auto_write=False,
                           pixel_order=ORDER)

def mix_it_up():
    global color
    for i in range(0, num_pixels, 11):
        for j in range(i, i+11):
            pixels[j] = color
        if(color == (255, 0, 0)):
            color = (0, 255, 0)
        else:
            color = (255, 0, 0)

def sound(note, duration):
def say():
    esng = ESpeakNG()
    esng.voice = "german"
    with open('D:/abc.txt', mode='r') as files:
        p = files.read(500)
    esng.say("hello world")
예제 #20
0
파일: chatbot.py 프로젝트: xamulap/chabot
##load gui
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"))
예제 #21
0
def parler(obj):
    logging.debug("Commande PARLER.")
    esng = ESpeakNG(voice='fr', speed=150, volume=10, pitch=90)
    esng.say(obj['phrase'], sync=True)
예제 #22
0
    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)


##
## Début du programme
##
    
esng = ESpeakNG()
print(esng.voices)
    
direTout();

while True:
    t = time.localtime()
    if t.tm_sec == 0:        ## Minute entière
        if t.tm_min == 0:    ## Heure entière
            direHeure(t)                    
        else:
            direHeureMin(t)
    else:
        time.sleep(1);

예제 #23
0
    def test_say_de(self):

        esng = ESpeakNG(voice='german')
        esng.pitch = 32
        esng.speed = 150
        esng.say('Wie geht es Dir?', sync=True)
예제 #24
0
    def test_voices(self):
        esng = ESpeakNG()

        voices = esng.voices
        self.assertGreater(len(voices), 10)
예제 #25
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
예제 #26
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)
예제 #27
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)
예제 #28
0
파일: eSpeak.py 프로젝트: bsu-slim/rr-sds
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.queue = deque()
        self.esp = ESpeakNG()
        self.iasr = IncrementalizeASRModule()
예제 #29
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)

예제 #30
0
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)