def __init__(self, name, voice, purpose, location, input, output, microphone):
"""Initializes assistant, adjusts for ambient noise, and checks TTS"""
self.name = name
self.name = self.name.lower()
self.purpose = purpose
self.voice = voice
self.location = location
self.r = sr.Recognizer()
self.mic = microphone
self.input = input
self.output = output
with sr.Microphone(device_index=self.mic, chunk_size=1024, sample_rate=48000) as source:
self.r.adjust_for_ambient_noise(source) # Adjust for ambient noise by listening for 1 second
# self.r.energy_threshold = 30 # Threshold offset
print ("\tThreshold: " + str(self.r.energy_threshold))
print("\tInitializing {}...".format(self.name))
self.speak("My name is " + self.name + " and I am here " + self.purpose + ". How may I help you?")
评论列表
文章目录