예제 #1
0
def play_sound(content):
    engine = pytts.Engine()
    engine.setProperty('rate', 220)  # 语速
    engine.setProperty('volume', 0.35)  # 音量
    engine.say(content)
    engine.runAndWait()
    engine.stop()
예제 #2
0
def do(cmd: command.Command):
    if cmd.object is None:
        e = pt.Engine()
        e.say('sorry sir, i do not understand that')
        e.runAndWait()
    else:
        cmd.object['main'].__call__(cmd)
def vc_cmnd(txt):
    pyttsx3.init()
    engine = pyttsx3.Engine(driverName='sapi5')
    engine.setProperty('rate', 128)
    engine.setProperty(
        'voice',
        'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_ZIRA_11.0'
    )
    engine.say(txt)
    engine.runAndWait()
예제 #4
0
def record_denoiser(cmd):
    e = pt.Engine()
    e.say("Recording a new noise file")
    e.runAndWait()
    e.say("please remain silent for the best possible effect")
    e.runAndWait()
    e.say("starting in 3, 2, 1")
    e.runAndWait()
    fs = 16000
    myrecording = sd.rec(int(4 * fs), samplerate=fs, channels=1, dtype='int16')
    sd.wait()  # Wait until recording is finished
    e.say("finished")
    e.runAndWait()
    sd.play(myrecording, fs)
    sd.wait()
    wav.write(f'./tmp/static.wav', fs, myrecording)
예제 #5
0
 def SetupVoiceEngine(self):
     #this function is use for septup voice engine and set the propeties of the engine like voice and rate
     try:
     #setup voice engine here 
         self.VoiceEngine = pyttsx3.Engine('sapi5')
         voice = self.VoiceEngine.getProperty("voices")
         if len(voice)>0:
             #set voice property of the engine
             self.VoiceEngine.setProperty('voice',voice[0])
         else:
             self._allWidgets["statusbar"].showMessage('No Voice Installed')
         #set rate property of engine
         self.VoiceEngine.setProperty('rate',100)
         
         self._allWidgets["statusbar"].showMessage("Voice Engine setup successfully")
     except Exception as e:
         print(e)
         self._allWidgets["statusbar"].showMessage('Unknown error occur')
예제 #6
0
def _get_voices(seq):
    seq = list(seq)
    if 0 in seq:
        gtts = True
        seq.remove(0)
    else:
        gtts = False
    voices = [voice.id for voice in pyttsx3.Engine().getProperty("voices")]
    if ... in seq:
        id_ns = list(range(1, len(voices) + 1))
        seq.remove(...)
        seq = list(filter(lambda x: x >= len(voices) + 1, seq))
        for i in seq:
            id_ns.remove(i)
    else:
        seq = list(filter(lambda x: x >= len(voices) + 1, seq))
        id_ns = seq
    return gtts, [voices[i - 1] for i in id_ns]
 def SetupVoiceEngine(self):
     #this function is use for septup voice engine and set the propeties of the engine like voice and rate
     try:
     #setup voice engine here 
         self.VoiceEngine = pyttsx3.Engine('sapi5')
         voice = self.VoiceEngine.getProperty("voices")
         if len(voice)>0:
             #set voice property of the engine
             self.VoiceEngine.setProperty('voice',voice[0])
         else:
             self.VoiceEngineLabel['text'] = 'No Voice Installed'
         #set rate property of engine
         self.VoiceEngine.setProperty('rate',100)
         
         self.VoiceEngineLabel['text'] = "Voice Engine setup successfully"
     except Exception as e:
         print(e)
         self.VoiceEngineLabel['text'] = 'Unknown error occur'
예제 #8
0
pip install speech_recognition
pip install wikipedia

also to run this program insternart is needed
"""
# ______modules______
import pyttsx3  # Enables Computer to speak
import speech_recognition as sr  # Recognize our Voice
import datetime  # Current Time
import wikipedia  # Search In WikiPedia In Present
import webbrowser  # To search In Browser
import os  # To Open File
import smtplib  # Send Emails

# ______Main Engine For PYTTSX3
engine = pyttsx3.Engine('sapi5')
voices = engine.getProperty('voices')
print(voices[1].id)
engine.setProperty('voice', voices[1].id)
# ______Functions______


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


def wishMe():
    hour = int(datetime.datetime.now().hour)
    if hour >= 0 and hour < 12:
        speak("Good Morning")
예제 #9
0
import requests
import speech_recognition as sr
import pyttsx3

API_KEY = "putapikeyhere"

engine = pyttsx3.Engine()
r = sr.Recognizer()

with sr.Microphone() as mic:
	print("What is the name of city?")
	engine.say("What is the name of city?")
	engine.runAndWait()
	city_name = r.recognize_google(r.listen(mic))
	print(city_name)
	print("What is the country code?")
	engine.say("What is the country code?")
	engine.runAndWait()
	country_code = r.recognize_google(r.listen(mic))
	print(country_code)
	print("What units, metric or imperial?")
	engine.say("What units, metric or imperial?")
	engine.runAndWait()
	units = r.recognize_google(r.listen(mic))
	print(units)

res = requests.get(f"https://api.openweathermap.org/data/2.5/weather?q={city_name},{country_code}&appid={API_KEY}&units={units}")
jsonRes = res.json()

print(jsonRes["main"]["temp"])
engine.say(jsonRes["main"]["temp"])
예제 #10
0
파일: gui.py 프로젝트: razyar/access-denied
def cmd_command():
	os.system('start cmd')
	r = spk.Engine()
	r.say('CMD Runned.')
	r.runAndWait()
예제 #11
0
파일: gui.py 프로젝트: razyar/access-denied
def about_command():
	r = spk.Engine()
	r.say('more repositores in github.com/razyar')
	r.runAndWait()
	Label = tkMessageBox.showinfo("About", "Force access denied notepad (you will not see any access denied here :) \n Download from: github.com/razyar \n more repo in github and khoderazyar.ir \n https://khoderazyar.ir")
예제 #12
0
def shutdown(cmd):
    e = pt.Engine()
    e.say("good bye sir")
    e.runAndWait()
    sys.exit(101)
예제 #13
0
 def __init__(self):
     self.default_settings = {}
     """see `pyttsx3 docs for available property settings <https://pyttsx3.readthedocs.io/en/latest/engine.html#pyttsx3.engine.Engine.setProperty>`_
     """
     self._ng = pyttsx3.Engine()