tts_baidu.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:tts-stray 作者: tweetyf 项目源码 文件源码
def TTSBaidu(self, tid, txt, lan, spd):
        ''' 
            get the BAIDU.COM's TTS url
            filename: save the txt's Speech in the file with filetype .wav
            lan: language, 'en' for English or 'zh' for Chinese
            txt: the TTS text
            spd: the speedding of read
        '''
        socket.setdefaulttimeout(34.0)
        try:
            #print('processing... ',tid, txt)
            ttsUrl = genTTSUrl(lan ,txt, spd)
            c = getpage(ttsUrl)
            #?master?????
            #print('processing...finished',tid)
            self.results[tid]=c
        except urllib.error.URLError as e:
            print("error:URLError ",e," we will try again...tid:",tid)
            self.TTSBaidu(tid, txt, lan, spd)
        except socket.timeout:
            print("error: TTSBaidu time out!, we will try again...tid:",tid )
            self.TTSBaidu(tid, txt, lan, spd)
        finally:
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号