• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyttsx.init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyttsx.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: playHand

def playHand(hand, wordList, n):
    score=0
    s=0
    while calculateHandlen(hand)>0:
        print 'Current Hand: ',
        displayHand(hand)
        print 'Enter word, or a "." to indicate that you are finished: '
        say1=('Enter word, or a dot to indicate that you are finished: ')
        #print (say1)
        engine=pyttsx.init()
        engine.say(say1)
        engine.runAndWait()
        engine.stop()
        del engine
        word=raw_input()
        if word=='.':
            break
        else:
            if isValidWord(word, hand, wordList)==False:
                say1=('Invalid word, please try again.')
                print (say1)
                engine=pyttsx.init()
                engine.say(say1)
                engine.runAndWait()
                engine.stop()
                del engine
            else:
                s=getWordScore(word, n)
                score+=s
                hand=updateHand(hand, word)
                say1=(word+' earned '+(str)(s)+' points. Total: '+str(score)+' points')
                print (say1)
                engine=pyttsx.init()
                engine.say(say1)
                engine.runAndWait()
                engine.stop()
                del engine
                if calculateHandlen(hand)==0:
                    break
    if word=='.':
        say1=('Goodbye! Total score: '+str(score)+' points.')
        print (say1)
        engine=pyttsx.init()
        engine.say(say1)
        engine.runAndWait()
        engine.stop()
        del engine
        time.sleep(0.5)
        say1=('Press r to replay the hand and then c to compare your score with the computer')
        print (say1)
        engine=pyttsx.init()
        engine.say(say1)
        engine.runAndWait()
        engine.stop()
        del engine
        time.sleep(0.5)
    else:
        print 'Run out of letters. Total score: '+str(score)+' points.'
开发者ID:sciencepal,项目名称:pyprojects,代码行数:58,代码来源:ps4a.py


示例2: sayText

def sayText(text):
##    engine = pyttsx.init()
##    engine.setProperty('rate', 150)
##    engine.say("lala")
##    engine.runAndWait()
    try:        
        engine = pyttsx.init()
        engine.setProperty('rate', 150)
        engine.say(text)
        engine.runAndWait()
    except:
        engine = pyttsx.init()
        engine.setProperty('rate', 150)
        engine.say("The image contains garbage text. Please upload another image.")
        engine.runAndWait()
开发者ID:nvysingla,项目名称:term-project,代码行数:15,代码来源:UI+version5.py


示例3: play_report

def play_report():
    pythoncom.CoInitialize()
    engine = pyttsx.init()
    rate = engine.getProperty('rate')
    engine.setProperty('rate', rate-10)
    time.sleep(2)
    if GLOBAL_STOP:
        return True
    engine.say('Good Morning... Uhh run... I hope you had a good sleep')
    engine.runAndWait()
    HueCommand(1, [BulbState(1, {'on' : True, 'bri' : 200, 'sat': 200, 'hue' : 46920, 'transitiontime' : 20}),
                   BulbState(2, {'on' : True, 'bri' : 200, 'sat': 200, 'hue' : 46920, 'transitiontime' : 20}),
                   BulbState(3, {'on' : True, 'bri' : 200, 'sat': 200, 'hue' : 46920, 'transitiontime' : 20})]).execute()
    if GLOBAL_STOP:
        return True
    engine.say(weather())
    engine.runAndWait()
    HueCommand(1, [BulbState(1, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 25000, 'transitiontime' : 20}),
                   BulbState(2, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 25000, 'transitiontime' : 20}),
                   BulbState(3, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 25000, 'transitiontime' : 20})]).execute()
    if GLOBAL_STOP:
        return True
    engine.say(quote())
    engine.runAndWait()
    if GLOBAL_STOP:
        return True
    # Deactivate
    engine.say("I hope you have a good day... Uhh run")
    HueCommand(1, [BulbState(1, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 12750, 'transitiontime' : 50}),
                   BulbState(2, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 12750, 'transitiontime' : 50}),
                   BulbState(3, {'on' : True, 'bri' : 200, 'sat': 175, 'hue' : 12750, 'transitiontime' : 50})]).execute()
    engine.runAndWait()
    return False
开发者ID:arank,项目名称:dorm-automation-script,代码行数:33,代码来源:morning_report.py


示例4: say_something

def say_something():
	"""
	test function
	"""
	engine = pyttsx.init()
	engine.say('Franchement, Precise Sad se ne vaut pas une bonne choucroute')
	engine.runAndWait()
开发者ID:Nurtal,项目名称:BIBOT,代码行数:7,代码来源:voice.py


示例5: ReadTheStringAloud

def ReadTheStringAloud(voiceName,voiceRate,speechString):
    '''
        Says speechString, using the default voice or voiceName voice
        Positive voiceRate is faster; Negative voiceRate is slower
        '''
    try:
        import pyttsx
        engine = pyttsx.init()
    except ImportError:
        print 'I did not find the pyttsx text to speech resources!'
        print str(err)
        usage()
        sys.exit(2)
    try:
        engine.setProperty('rate', engine.getProperty('rate')+int(voiceRate))
    except Error:
        print ('I did not understand the rate!')
        usage()
        sys.exit(2)
    voices = engine.getProperty('voices')
    for voice in voices:
        if voice.name == voiceName:
            engine.setProperty('voice', voice.id)
            break
    engine.say(speechString)
    engine.runAndWait()
开发者ID:jimholgate,项目名称:ability-tools,代码行数:26,代码来源:pyttsx_read_text_file.py


示例6: Speak

def Speak(phrase):
    engine = pyttsx.init()
    voices = engine.getProperty("voices")
    engine.setProperty("rate", 175)
    engine.setProperty("voice", 2)
    engine.say(phrase)
    engine.runAndWait()
开发者ID:Windows65,项目名称:HS-Projects,代码行数:7,代码来源:Hexobot_Main_Brain.py


示例7: speakToMe

def speakToMe(what, **justwith):
    """
    speak to me about something with some special
    justwith key:
        "speed": "slow","medium","fast"
        "faster": number type (1-10)
        "volume": "low", "medium","loud"
        "louder": number type(0.01-0.1)
    """
    defspeed={"slow":0.01,"medium":80,"fast":210}
    defvolume={"low":0.3,"medium":0.5,"loud":1}
    engine = pyttsx.init("espeak")
    engine.setProperty('languages','zh')
    if justwith == None :
        # Just say out
        engine.say(what)
    else:
        if justwith['speed'] != None:
            engine.setProperty('rate',defspeed[justwith['speed']])
        if justwith['volume']!= None:
            engine.setProperty('volume', defvolume[justwith['volume']])
        if justwith['faster'] != None:
            if isinstance(justwith['faster'], int):
                sp = engine.getProperty('rate')
                engine.setProperty('rate',sp+justwith['faster'])
        if justwith['louder'] != None:
            if isinstance(justwith['louder'], float):
                vo = engine.getProperty('volume')
                engine.setProperty('volume',vo+justwith['louder'])
        engine.say(what)
        engine.runAndWait()
开发者ID:roubo,项目名称:mqttpy,代码行数:31,代码来源:doSubandPub.py


示例8: feedback

def feedback():
    engine = pyttsx.init()
    engine.setProperty("rate", 110)
    voices = engine.getProperty("voices")
    engine.setProperty("voice", "english-scottish")
    engine.say("Message Sent")
    engine.runAndWait()
开发者ID:toriqyan,项目名称:prototype0,代码行数:7,代码来源:texting.py


示例9: sap

def sap(thistext):
    engine = pyttsx.init()
    rate = engine.getProperty('rate')
    engine.setProperty('rate', rate-50)
    engine.say(thistext)
    print(thistext)
    engine.runAndWait()
开发者ID:josetheworm,项目名称:console,代码行数:7,代码来源:functions.py


示例10: speak_ICAO

def speak_ICAO(text):
	t = make_msg(text)
	engine = pyttsx.init()
	engine.setProperty('rate', 120)
	for i in t:
		engine.say(i)
	engine.runAndWait()
开发者ID:eltsip,项目名称:py_exercises,代码行数:7,代码来源:speak_ICAO.py


示例11: say_pyttsx

 def say_pyttsx(self, txt):
     txt = random.choice(txt)
     print 'HAL >>> ' + txt
     speech = pyttsx.init()
     speech.say(txt)
     speech.runAndWait()
     del speech
开发者ID:ggomarr,项目名称:HAL,代码行数:7,代码来源:speaker.py


示例12: __init__

    def __init__(self):
        pygame.init()
        pygame.mixer.init(buffer=1024)
        pygame.mixer.set_num_channels(13)
        pygame.mixer.set_reserved(13)
        self.engine=pyttsx.init()

        self.eating_sound=pygame.mixer.Sound("sounds/eat.wav")
        self.hit_sound=pygame.mixer.Sound("sounds/ghost_hit.wav")
        self.bump_sound=pygame.mixer.Sound("sounds/bump.wav")
        self.misc_sound_channel=pygame.mixer.Channel(10)
        self.misc_sound_channel.set_volume(1.0, 1.0)
        
        self.screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
        self.font=pygame.font.SysFont(pygame.font.get_default_font(), 72)
        self.key_held_down=False
        self.pacman_visible=True
        
        self.leftWall=pygame.Rect(0, 0, WALL_THICKNESS, HEIGHT)
        self.topWall=pygame.Rect(0+WALL_THICKNESS, 0, WIDTH-WALL_THICKNESS, WALL_THICKNESS)
        self.rightWall=pygame.Rect(WIDTH-WALL_THICKNESS, 0+WALL_THICKNESS, WALL_THICKNESS, HEIGHT-WALL_THICKNESS)
        self.bottomWall=pygame.Rect(0+WALL_THICKNESS, HEIGHT-WALL_THICKNESS, WIDTH-2*WALL_THICKNESS, WALL_THICKNESS)

        self.level=1
        self.score=0
        self.lives=4
        self.engine.say('Welcome to Fruit Man! You are wandering in a field and very hungry.')
        self.engine.say('Try to collect all of the fruits using the sounds in your ears, but')
        self.engine.say('don\'t hit the ghosts! They want to eat you as well. Good luck!')
        self.engine.runAndWait()
        self.gameRunning=True
        self.gameJustEnded=False
开发者ID:computerscientist,项目名称:code_samples,代码行数:32,代码来源:fruit_man.py


示例13: talk

def talk(text):
    # Talk to the user
    engine = pyttsx.init()
    engine.setProperty('rate', 100)
    engine.setProperty('volume', 100)
    engine.say(text)
    engine.runAndWait()
开发者ID:jfperez,项目名称:Python_Bootcamp,代码行数:7,代码来源:TennisBot.py


示例14: TTS

def TTS(string):
	"""
	입력된 단어를 읽어줍니다.
	"""
	engine = pyttsx.init()
	engine.say(string)
	engine.runAndWait()
开发者ID:speark,项目名称:voca_py,代码行数:7,代码来源:wtf_toeic.py


示例15: gest_callback

    def gest_callback(self, gesture):

        # if different gesture is being detected, begin timer
        if gesture.data != self.current_gesture:
            self.last_message_time = self.millis()

        # Calculate time elapsed
        delta_time = self.millis() - self.last_message_time

        # if no gesture is detected or an old gesture is detected, cut music and update current gesture
        if gesture.data == '' or (self.previous_gesture == gesture.data):
            self.current_gesture = ""
            pygame.mixer.music.stop()

        # Else if time has not elapsed and a new gesture is detected, play music. Also, update current gesture
        elif (delta_time < self.match_time) and (self.previous_gesture != gesture.data):
            if not pygame.mixer.music.get_busy():
                pygame.mixer.music.load(self.audio_path)
                pygame.mixer.music.play()
            self.current_gesture = gesture.data

        # Else if time has elapsed and we have a new gesture, stop beeping, play voice, and update gestures and time.
        elif (gesture.data != self.previous_gesture) and (delta_time >= self.match_time):
            engine = pyttsx.init('espeak')
            engine.setProperty('rate', 100)
            while engine.isBusy():
                pygame.mixer.music.stop()
                engine.say(unicode(str(gesture.data)), "utf-8")
                engine.runAndWait()
                self.previous_gesture = gesture.data
                self.last_message_time = self.last_message_time
开发者ID:ogiovanniruiz,项目名称:rosc_simple_gesture,代码行数:31,代码来源:audio_feedback.py


示例16: main

def main(speech):
    
    engine=pyttsx.init()
    engine.setProperty('rate',150)
    engine.setProperty('voice','en-wims')
    engine.say(speech)
    engine.runAndWait()
开发者ID:gpratyush,项目名称:Yam,代码行数:7,代码来源:talks.py


示例17: tts

 def tts(self, text):
     print '* tts:', text
     engine = pyttsx.init()
     engine.setProperty('voice', self.tts_voice_id)
     engine.setProperty('rate', self.tts_voice_rate)
     engine.say(text)
     engine.runAndWait()
开发者ID:katzoo,项目名称:amu,代码行数:7,代码来源:sts-moses.py


示例18: main

def main():
	if len(sys.argv) < 2:
		return
	text = sys.argv[1]
	engine = pyttsx.init()
	engine.say(text)
	engine.runAndWait()
开发者ID:jrm98,项目名称:voice-assistant,代码行数:7,代码来源:speech.py


示例19: speak

    def speak(self,sentence):
        """
            This function says sentence

            Input:
            sentence        - String sentence

            Returns:
            Nothing
        """
        import pyttsx

        with self._voice_lock:
            engine = pyttsx.init()

            if isinstance(sentence,list):
                sentence = " ".join(sentence)
            elif isinstance(sentence,str): pass
            else:
                raise VoiceException("Wrong sentence type: " + str(type(sentence)))

            engine.setProperty('volume',self._volume)
            engine.setProperty('rate',self._rate)
            engine.say(sentence)

            engine.runAndWait()
            engine.stop()

            del engine
开发者ID:0x1001,项目名称:jarvis,代码行数:29,代码来源:voice.py


示例20: speak

def speak(str):
    print(str)
    engine = pyttsx.init()
    rate = engine.getProperty('rate')
    engine.setProperty('rate', rate + 0.5)
    engine.say(str)
    engine.runAndWait()
开发者ID:hannemtr,项目名称:Selfiestick,代码行数:7,代码来源:SelfieScript.py



注:本文中的pyttsx.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pytube.YouTube类代码示例发布时间:2022-05-27
下一篇:
Python mpi.is_master_node函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap