Example #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
Example #2
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, [])
Example #3
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, [])
Example #4
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)
Example #5
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)
Example #6
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 rainbow_cycle(wait):
    for j in range(255):
        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
Example #8
0
    def test_say_de(self):

        esng = ESpeakNG(voice='german')
        esng.pitch = 32
        esng.speed = 150
        esng.say('Wie geht es Dir?', sync=True)
Example #9
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
        if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN
                                         and event.key == pygame.K_ESCAPE):