Exemple #1
0
    def say_line(self, ligne=''):
        jj = os.path.join

        ligne = to_u(ligne)
        f = codecs.open('/tmp/resu.txt','w', 'utf-8')
        f.write(ligne)
        f.close()
        
        if self.langue == 'french':
            os.system('iconv -f utf8 -t latin1 /tmp/resu.txt > /tmp/resu_1.txt')
            comm = 'export LIA_PHON_REP="%s" && %s < /tmp/resu_1.txt > /tmp/resu.ola' % (rep_lia_phon, lia_text2mbrola)
            os.system(comm)
            comm = 'export LIA_PHON_REP="%s" && %s -v %f -f %f -t %f -I %s %s /tmp/resu.ola /tmp/resu.au' % (
                rep_lia_phon,
                mbrola, self.vol, self.freq, self.dur,
                lia_initfile, jj(rep_voices,self.personne))
            os.system(comm)

        if self.langue == 'turk':
            turc2phn.text2phn('/tmp/resu.txt')
            comm = '/data/tts/mbrola /data/tts/voices/turc1 /tmp/resu.txt.pho  /tmp/resu.wav'
            os.system(comm)

        if self.langue == 'english':
            english2phn.text2phn('/tmp/resu.txt')
            comm = '/data/tts/mbrola /data/tts/voices/en1 /tmp/resu.txt.pho  /tmp/resu.wav'
            os.system(comm)
Exemple #2
0
    def say_line(self, ligne='', langue='turk', newfreq=None, newdur=None, newvol=1):
        jj = os.path.join
        if newfreq: self.freq = newfreq
        if newdur: self.dur = newdur
        if newvol: self.vol = newvol

        # f = codecs.open('/tmp/resu.txt','w', 'utf-8')
        ligne = to_u(ligne)
        f = codecs.open('/tmp/resu.txt','w', 'utf-8')
        f.write(ligne)
        f.close()
        
        if langue == 'french':
            os.system('/usr/bin/iconv -f utf8 -t latin1 /tmp/resu.txt > /tmp/resu_1.txt')
        # os.system('rm /data/prog/resu.txt')
            comm = 'export LIA_PHON_REP="%s" && %s < /tmp/resu_1.txt > /tmp/resu.ola' % (rep_lia_phon, lia_text2mbrola)
            os.system(comm)
            comm = 'export LIA_PHON_REP="%s" && %s -v %f -f %f -t %f -I %s %s /tmp/resu.ola /tmp/resu.au' % (
                rep_lia_phon,
                mbrola, self.vol, self.freq, self.dur,
                lia_initfile, jj(rep_voices,self.personne))
            os.system(comm)

            os.system('%s /tmp/resu.au -r 44100 /tmp/resu.wav' % sox)
            # os.system(mplayer+' -af extrastereo=0 -nolirc -really-quiet /tmp/resu.au &')
            dursec = get_sndfile_duration('/tmp/resu.au')
            os.system('"/Applications/MPlayer OSX Extended.app/Contents/Resources/Binaries/mpextended.mpBinaries/Contents/mpextended.mpBinaries/Contents/MacOS/mplayer" /tmp/resu.au &')

        if langue == 'turk':
            turc2phn.text2phn('/tmp/resu.txt')
            comm = '/data/tts/mbrola /data/tts/voices/turc1 /tmp/resu.txt.pho  /tmp/resu.wav'
            os.system(comm)
            dursec = get_sndfile_duration('/tmp/resu.wav')
            os.system(mplayer + ' -nolirc -really-quiet /tmp/resu.wav &')

        if langue == 'english':
            english2phn.text2phn('/tmp/resu.txt')
            comm = '/data/tts/mbrola /data/tts/voices/en1 /tmp/resu.txt.pho  /tmp/resu.wav'
            os.system(comm)
            dursec = get_sndfile_duration('/tmp/resu.wav')
            os.system(mplayer + '-nolirc -really-quiet /tmp/resu.wav &')

        return dursec