예제 #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
예제 #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, [])
예제 #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, [])
예제 #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)
예제 #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)
예제 #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

time.sleep(1)
예제 #8
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)
예제 #9
0
    def test_say_de(self):

        esng = ESpeakNG(voice='german')
        esng.pitch = 32
        esng.speed = 150
        esng.say('Wie geht es Dir?', sync=True)
예제 #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_()
예제 #11
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