def __init__(self, engine, language, day=None): self.engine = engine self.language = language self.day = day or Day() self.scheduler = sched.scheduler(datetime.datetime.now, sleep_timedelta) self.talker = talkey.Talkey(preferred_languages=[self.language], engine_preference=[self.engine])
def playMessage(Message): try: # Voice Feature tts = talkey.Talkey(preferred_languages=['en'], preferred_factor=80.0, engine_preference=['espeak']) tts.say(Message) except Exception as e: return 0 return 1
def OnEnter(self,event): input =self.txt.GetValue() input =input.lower() if input == "": r=sr.Recognizer() with sr.Microphone() as source: audio=r.listen(source) try: self.txt.SetValue(r.recognize_google(audio)) except sr.UnknownValueError: print("Google Speech Recognition could not understand audio") except sr.ReqestError as e: print("Could not request results from google Speech Recognition Service; {0} ".format(e)) else: try: #wolframalpha app_id ="976492-LH43H5QT5V" client =wolframalpha.Client(app_id) res=client.query(input) answer=next(res.results).text print answer tts = talkey.Talkey() tts.say(answer) except: #wikipedia stopwords = ['what','who','is','a','at','is','he'] querywords = input.split() resultwords = [word for word in querywords if word.lower() not in stopwords] input = ' '.join(resultwords) tts = talkey.Talkey() tts.say('Results are ready') print wikipedia.summary(input)
def say(rand, n, mixer): tts = talkey.Talkey( # The order of preference of using a TTS engine for a given language. # Note, that networked engines (Google, Mary) is disabled by default, and so is dummy # default: ['google', 'mary', 'espeak', 'festival', 'pico', 'flite', 'dummy'] # This sets eSpeak as the preferred engine, the other engines may still be used # if eSpeak doesn't support a requested language. engine_preference=['espeak'], # Here you segment the configuration by engine # Key is the engine SLUG, in this case ``espeak`` espeak={ # Specify the engine options: 'options': { 'enabled': True, }, # Specify some default voice options 'defaults': { 'words_per_minute': 135, }, # Here you specify language-specific voice options # e.g. for english we prefer the mbrola en1 voice 'languages': { 'en': { 'voice': 'english-mb-en1', 'words_per_minute': 114, 'pitch_adjustment': 60 }, } }) tts.say(random.choice(rand)) ''' This is old programs ''' #The old code, use this if you want a higher quality voice, requires internet however. ''' tts = gTTS(text=random.choice(rand), lang = 'en-au') tts.save('ArcVoice.mp3') mixer.init() mixer.music.load('ArcVoice.mp3') mixer.music.play() ''' """
class Emse_speech_producer: """ A singelton class that produces speech based on the text param passed to the say() method. """ __singleton = None __lock = threading.Lock() __tts = talkey.Talkey() def __new__(cls, *args, **kwargs): if not cls.__singleton: cls.__singleton = object.__new__(Emse_speech_producer) return cls.__singleton def say(self, text): """ Launches a new thread to output the speech without blocking the excution of the current thread""" #Run a separate thread to produce the speech thread.start_new_thread(self.thread_say, (text, )) def thread_say(self, text): """ Produce the speech output with the insurance that a single thread is producing speech - Lock - """ #Try to Acquire the lock if self.__lock.acquire(blocking=False): self.__tts.say(text) self.__lock.release()
import talkey tts = talkey.Talkey() tts.say("Hello. I am ARDOP. How are you? What can I do for you?") # import talkey # tts = talkey.Talkey( # # These languages are given better scoring by the language detector # # to minimise the chance of it detecting a short string completely incorrectly. # # Order is not important here # preferred_languages=['en', 'af', 'el', 'fr'], # # The factor by which preferred_languages gets their score increased, defaults to 80.0 # preferred_factor=80.0, # # The order of preference of using a TTS engine for a given language. # # Note, that networked engines (Google, Mary) is disabled by default, and so is dummy # # default: ['google', 'mary', 'espeak', 'festival', 'pico', 'flite', 'dummy'] # # This sets eSpeak as the preferred engine, the other engines may still be used # # if eSpeak doesn't support a requested language. # engine_preference=['espeak'], # # Here you segment the configuration by engine # # Key is the engine SLUG, in this case ``espeak`` # espeak={ # # Specify the engine options: # 'options': { # 'enabled': True, # }, # # Specify some default voice options # 'defaults': {
def speak(self, text): voice = talkey.Talkey(engine_preference=['pico']) text = str(text) voice.say(text + '....')
args = parser.parse_args() ################################################################## #init program global variables ################################################################## phrase = '' maxBackgroundStartVolume = args.maxBackgroundStartVolume maxBackgroundStartCrossings = args.maxBackgroundStartCrossings seconds = args.seconds jsonFile = args.jsonFile strictMatch = args.strictMatch numActualRecordedFrames = 0 maxFramesBeforeTrim = int(RATE / CHUNK * seconds) textToSpeech = talkey.Talkey(preferred_language=['en']) p = pyaudio.PyAudio() # Create an interface to PortAudio f = Figlet() phrasesArray = [] quitProgram = False ################################################################## def listPhrasesTrained(): listedPhrases = [] for phrase in phrasesArray: #print(listedPhrases) if not phrase['phrase'] in listedPhrases:
os.system("mpg321 good.wav") time.sleep(1) tts = talkey.Talkey( engine_preference=['espeak'], # Here you segment the configuration by engine # Key is the engine SLUG, in this case ``espeak`` espeak={ # Specify the engine options: 'options': { 'enabled': True, }, # Specify some default voice options 'defaults': { 'words_per_minute': 150, 'variant': 'f4', }, # Here you specify language-specific voice options # e.g. for english we prefer the mbrola en1 voice 'languages': { 'en': { 'voice': 'english-mb-en1', 'words_per_minute': 130 }, } }) tts.say(textInput)
def __init__(self): self.engine = talkey.Talkey()
def speak(text): voice = talkey.Talkey(engine_preference=['pico']) voice.say(text + '....')
tts = talkey.Talkey( # These languages are given better scoring by the language detector # to minimise the chance of it detecting a short string completely incorrectly. # Order is not important here preferred_languages=['es', 'en'], # The factor by which preferred_languages gets their score increased, defaults to 80.0 preferred_factor=80.0, # The order of preference of using a TTS engine for a given language. # Note, that networked engines (Google, Mary) is disabled by default, and so is dummy # default: ['google', 'mary', 'espeak', 'festival', 'pico', 'flite', 'dummy'] # This sets eSpeak as the preferred engine, the other engines may still be used # if eSpeak doesn't support a requested language. engine_preference=['espeak'], # Here you segment the configuration by engine # Key is the engine SLUG, in this case ``espeak`` espeak={ # Specify the engine options: 'options': { 'enabled': True, }, # Specify some default voice options 'defaults': { 'words_per_minute': 150, 'variant': 'f4', }, # Here you specify language-specific voice options # e.g. for english we prefer the mbrola en1 voice 'languages': { 'en': { 'voice': 'english-mb-en1', 'words_per_minute': 130 }, } } )
def talk(phrase): sys.stderr.write(phrase + "\n") text_to_speech = talkey.Talkey(preferred_languages=['fr', 'en']) text_to_speech.say(phrase)