Exemple #1
0
def speak(text):
    engineio = pyttsx3.init()
    voices = engineio.getProperty('voices')
    engineio.setProperty('rate',
                         130)  # Aquí puedes seleccionar la velocidad de la voz
    engineio.setProperty('voice', voices[0].id)
    engineio.say(text)
    engineio.runAndWait()
Exemple #2
0
def speak():
    "SPEAK 是存放输入字符串的列表,定义正全局变量"
    engineio = pyttsx3.init()  # 初始化
    voices = engineio.getProperty('voices')
    engineio.setProperty('rate', 130)  # 这里是管控语音速度的
    engineio.setProperty('voice', voices[0].id)

    if len(SPEAK):
        engineio.say(SPEAK[len(SPEAK) - 1])  # 获取最新输入的值
        engineio.runAndWait()
        data = SPEAK[0]
        if data != SPEAK[len(SPEAK) - 1]:  # 比较两个值要是不同就证明有新的值进入了,将原先的给删除掉
            del SPEAK[0]
    else:
        engineio.say("请输入你要翻译的英文或者汉字")
        engineio.runAndWait()
        sys.exit()
Exemple #3
0
def Voice():
    engineio = pyttsx3.init()
    voices = engineio.getProperty('voices')
    engineio.setProperty('rate', 130)
    engineio.setProperty('voice', voices[0].id)

    def speak(text):
        engineio.say(text)
        engineio.runAndWait()

    engineio = pyttsx3.init()
    voices = engineio.getProperty('voices')

    r = sr.Recognizer()
    #r.energy_threshold = 4000
    mic = sr.Microphone()

    while 1:

        with mic as source:
            print('Listening...')
            text = 'Listening...'
            speak(text)

            audio = r.listen(source)
            #r.adjust_for_ambient_noise(source, duration=0.5)
            #r.dynamic_energy_threshold = True        # listen to the source
            try:
                # use recognizer to convert our audio into text part.
                text = r.recognize_google(audio)
                print("You said : {}".format(text))
            except:
                # In case of voice not recognized  clearly
                print("Sorry could not recognize your voice")
                speak("Could not understand")

        if text == 'exit':
            equation.set('Good Bye :D')
            root.update_idletasks()
            speak("Good Bye")
            break
            #sys.exit("Thankyou !")
        elif text == "clear":
            equation.set(" ")

        a = ''
        b = ''
        i = 0
        j = 0
        c = len(text)
        while text[j] != ' ':
            a = a + text[j]
            j = j + 1
        j = j + 1
        ch = text[j]
        if ch == 'd':
            while text[j] != 'y':
                j = j + 1
            #j=j+1
        j = j + 2
        while j != c:
            b = b + text[j]
            j = j + 1

        a = float(a)
        b = float(b)

        ans = 0
        if ch == '+':
            ans = a + b
            equation.set(ans)
            root.update_idletasks()

        elif ch == '-':
            ans = a - b
            equation.set(ans)
            root.update_idletasks()

        elif ch == 'x' or ch == 'X':
            ans = a * b
            equation.set(round(ans, 2))
            root.update_idletasks()

        elif ch == '/' or ch == 'd':
            if b != 0:
                ans = a / b
                equation.set(round(ans, 2))
                root.update_idletasks()
            else:
                speak("Not defined")
                ans = 0
                #equation.set(round(ans,2))
                root.update_idletasks()
        elif ch == '^':
            ans = math.pow(a, b)
            equation.set(ans)
            root.update_idletasks()
        else:
            ans = "Invalid Command"

        print(round(ans, 2))
        equation.set(ans)
        speak("The answer is {}".format(round(ans, 2)))
Exemple #4
0
import speech_recognition as sr
from tkinter import *
from tkinter import messagebox
import random
import time
import datetime
import smtplib
import pyttsx3
import winsound
import engineio
import string
from random import randint
engineio = pyttsx3.init()
voices = engineio.getProperty('voices')
engineio.setProperty('rate', 130)
engineio.setProperty('voice', voices[0].id)
frequency = 4500
duration = 150


def speak(text):
    engineio.say(text)
    engineio.runAndWait()


#speak("hello world")

# creating root object
root = Tk()

# defining size of window
Exemple #5
0
def Voice():
    engineio = pyttsx3.init()
    voices = engineio.getProperty('voices')
    engineio.setProperty('rate', 130)
    engineio.setProperty('voice', 'ru')
    engineio.setProperty('voice', voices[0].id)

    def speak(text):
        engineio.say(text)
        engineio.runAndWait()

    engineio = pyttsx3.init()
    voices = engineio.getProperty('voices')

    r = sr.Recognizer()
    r.energy_threshold = 4000
    mic = sr.Microphone()

    while 1:

        with mic as source:
            print('Слушаю...')
            text = 'Слушаю...'
            speak(text)

            audio = r.listen(source)
            r.adjust_for_ambient_noise(source, duration=0.5)
            r.dynamic_energy_threshold = True  # listen to the source
            try:
                # use recognizer to convert our audio into text part.
                text = r.recognize_google(audio, language="ru_RU")
                print("Вы сказали : {}".format(text))
            except:
                # In case of voice not recognized  clearly
                print("Извините,не могу опознать голос")
                speak("Не могу опознать вашу команду")

        if text == 'выход' or text == 'выйти' or text == 'закрыть' or text == 'остановить' or text == 'выйти':
            equation.set('Начинаю подсчёт... ')
            root.update_idletasks()
            speak("Вы в режиме обычного калькулятора!")
        #elif text =='закрыть' or text=='Закрой'or text=='закончить': doesn't work correctly
        # sys.exit("До Свидания , Хорошего дня !")
        elif text == "Очисти" or text == 'сотри' or text == 'стереть':
            equation.set(" ")

        a = ''
        b = ''
        i = 0
        j = 0
        c = len(text)
        while text[j] != ' ':
            a = a + text[j]
            j = j + 1
        j = j + 1
        ch = text[j]
        if ch == 'd':
            while text[j] != 'y':
                j = j + 1
            #j=j+1
        j = j + 2
        while j != c:
            b = b + text[j]
            j = j + 1

        a = float(a)
        b = float(b)

        ans = 0
        if ch == '+' or ch == 'плюс' or ch == 'добавить' or ch == 'прибавить':
            ans = a + b
            equation.set(ans)
            root.update_idletasks()

        elif ch == '-' or ch == 'минус' or ch == 'отнять' or ch == 'вычесть':
            ans = a - b
            equation.set(ans)
            root.update_idletasks()

        elif ch == 'x' or ch == 'умножить' or ch == 'на' or ch == 'ножить':
            ans = a * b
            equation.set(round(ans, 2))
            root.update_idletasks()

        elif ch == '/' or ch == 'поделить' or ch == 'разделить' or ch == 'делить':
            if b != 0:
                ans = a / b
                equation.set(round(ans, 2))
                root.update_idletasks()
            else:
                speak("Не определено")
                ans = 0
                #equation.set(round(ans,2))
                root.update_idletasks()
        elif ch == '^' or ch == 'в' or ch == 'во' or ch == 'степень' or ch == 'степени' or ch == 'епень':
            ans = math.pow(a, b)
            equation.set(ans)
            root.update_idletasks()
        else:
            ans = "Некорректная команда"

        print(round(ans, 2))
        equation.set(ans)
        speak("Ответ: {}".format(round(ans, 2)))
import pyttsx3
import engineio
import sys
import re

engineio = pyttsx3.init()
voices = engineio.getProperty('voices')
engineio.setProperty('rate',
                     130)  # Aquí puedes seleccionar la velocidad de la voz
engineio.setProperty('voice', voices[2].id)


def speak(text):
    engineio.say(text)
    engineio.runAndWait()


# speak("The quick brown fox jumped over the lazy dog.")

# for voice in voices:
#    engineio.setProperty('voice', voice.id)
#    print(voice)
#    print("\n")
#    speak('f**k off griffin')

inputfile = None
voiceId = 0
for arg in sys.argv[1:]:
    k, v = arg.split('=')
    if (k == "input_file"):
        inputfile = v
Exemple #7
0
# Fetch the service account key JSON file contents
cred = credentials.Certificate('/Users/mac/Documents/GitHub/Autonomous-Car/AI/alphanumbraskem-firebase.json')

# Initialize the app with a service account, granting admin privileges
firebase_admin.initialize_app(cred, {
    'databaseURL': 'https://alphanumbraskem.firebaseio.com/'
})

nome = db.reference('/profiles/funcionario1/nome')
planta = db.reference('/plantas/id')

engineio = pyttsx3.init() #inicializa a engine
voices = engineio.getProperty('voices')

engineio.setProperty('rate', 130)    # Aquí puedes seleccionar la velocidad de la voz
# engineio.setProperty('voice',voices[0].id) # escolhe a voz a ser falada
engineio.setProperty('voice', b'brazil') # passando a voz para ptbr

def speak(text):
    engineio.say(text) # fala a string setada
    engineio.runAndWait() # executa e espera

# fala incial de boas vindas
speak('Olá, ' + str(nome.get()) + '! Meu nome é, Alfa!')
# speak('Hello, ' + str(nome.get()) + '! My name is, Alpha!')

# fala sobre destino de plantas
if str(planta.get()) == 'pv14':
    speak('Próximo destino: PV14')
    # speak('Next station: PV14')
Exemple #8
0
#import vlc
from time import strftime
import getpass
import random
import pyttsx3
import engineio
import subprocess
import pyfiglet

# Abilities Imports
from abilities import website, reddit, weather, \
    joke, news, application, knowledge

# engineio
engineio = pyttsx3.init()
engineio.setProperty('rate', 100)
voices = engineio.getProperty('voices')
engineio.setProperty('voice', 'english+f4')

# Get username of device
username = getpass.getuser()


# convert text to speech
def GLaDOS(audio):
    """speaks audio passed as argument"""
    print(audio)
    for line in audio.splitlines():
        engineio.say(audio)
        engineio.runAndWait()
Exemple #9
0
import speech_recognition as sr
import os
import pyttsx3
import engineio

# Initializing Programs Voice
engineio = pyttsx3.init()
voices = engineio.getProperty('voices')
engineio.setProperty('rate', 120)
engineio.setProperty('voice', voices[1].id)


def isValidCreateTask(user_input):

    strin = user_input
    strin = list(strin.split(' '))
    approved_words = []

    for i in strin:
        if i == "create":
            approved_words.append(i)
        elif i == "task":
            approved_words.append(i)
        elif i == "add":
            approved_words.append(i)
        elif i == "stop":
            approved_words.append(i)
        else:
            continue

    flag = 0
import speech_recognition as sr
import pyttsx as pys
import engineio
import datetime
import wikipedia
import os
import webbrowser
import playsound
from gtts import gTTS

engineio = pys.init()
engineio.setProperty('rate', 150)
voices = engineio.getProperty('voices')
engineio.setProperty('voice', voices[1].id)
volume = engineio.getProperty('volume')
engineio.setProperty('volume', 1.0)


def speak(audio):
    engineio.say(audio)
    engineio.runAndWait()


def saveVoice(audio):
    tts = gTTS(text=audio)
    filename = "voice.mp3"
    tts.save(filename)
    playsound.playsound(filename)


def Command():