示例#1
0
 def _talk():
     """Pronounces the given text in the given language."""
     with TALK_LOCK:
         tpath = op.join(tempfile.gettempdir(),
                         f"__temp-talk-{randomize(6)}.mp3")
         tts(text=text, lang=lang, slow=slow).save(tpath)
         playsound(tpath)
         delete(tpath)
示例#2
0
def my_tts(aud_txt):
    if aud_txt.startswith('http') == True:
        say = 'Here is a link to a cat picture!, you shoud copy this link and paste in the browser to view the picture.'
    else:
        say = re.sub(r'\w+:\/{2}[\d\w-]+(\.[\d\w-]+)*(?:(?:\/[^\s/]*))*',
                     'the link on the screen', aud_txt)
    tts(text=say, lang='en', slow=False).save('say.mp3')
    ps('say.mp3')
    os.remove("say.mp3")
def speak(text):
    """Say something"""

    # Write output to console
    print(text)

    # Save audio file
    speech = tts(text=text, lang='tr')
    speech_file = 'input.mp3'
    speech.save(speech_file)

    # Play audio file
    sound = AudioSegment.from_mp3(speech_file)
    play(sound)
    os.remove(speech_file)
#%%
    
    if __name__ == "__main__":
        # First get name
        speak('İsminiz ne?')
        name = capture()
        speak('Merhaba, ' + name + '.')
    # Then just keep listening & responding
    while 1:
        speak('Görüşmenin tamamlanması için ne söylemelisiniz?')
        captured_text = capture().lower()

        if captured_text == 0:
            continue

        if 'bitti' in str(captured_text):
            speak('Tamam, tekrar görüşmek üzere. Selamlar, ' + name + '.')
            break
        # Process captured text
        process_text(name, captured_text)
示例#4
0
def speak(save=True, file_name='./last_output.wav'):
    text = sys.argv[-1]
    lang = 'en-us'
    speech = tts(text, lang)
    if save:
        speech.save(file_name)
    return speech
def spconvert(fname):
    txt1 = ""
    with open(fname, "r") as file:
        for line in file:
            txt1 += line
    speech = tts(txt1, 'en')
    speech.save("spout.mp3")
    os.system('start spout.mp3')
示例#6
0
 def playText(self, text):
     sound = tts(text, 'en')
     sound.save(self.path)
     soundfile = open(self.path, "r")
     pygame.mixer.music.load(soundfile)
     pygame.mixer.music.play()
     while pygame.mixer.music.get_busy():
         pygame.time.Clock().tick(10)
     soundfile.close()
示例#7
0
def speak(text):
    """Say something"""

    # Write output to console
    print(text)

    # Save audio file
    speech = tts(text=text, lang='en', slow=False)
    speech_file = 'input.wave'
    speech.save(speech_file)
示例#8
0
def speak(text):
    """Say something"""
    # Write output to console
    print(text)
    # Save audio file
    speech = tts(text=text, lang='en')
    speech_file = 'input.mp3'
    speech.save(speech_file)
    # Play audio file
    sound = AudioSegment.from_mp3(speech_file)
    play(sound)
    os.remove(speech_file)
示例#9
0
def speak(text='', speech_file='output/input.mp3', delete_tmp_audio=False):
    """Say something"""

    # Save audio file
    if text:
        speech = tts(text=text, lang='en')
        speech.save(speech_file)

    # Play audio file
    sound = AudioSegment.from_mp3(speech_file)
    play(sound)
    if delete_tmp_audio:
        os.remove(speech_file)
def speak(text):
    # Write output to console
    print(text)

    # save audio file
    speech = tts(text=text, lang='ml')
    speech_file = 'input.mp3'
    speech.save(speech_file)

    # Play audio file
    sound = AudioSegment.from_mp3(speech_file)
    play(sound)
    # engine = pyttsx3.init()
    # engine.say(speech_file)
    os.remove(speech_file)
def create_audio(path):
    with open(path, 'r', encoding='utf-8') as file:
        table = pd.read_csv(file, sep=';')['word']
    # table = ['sinebu', 'reketre', 'fentime', 'varansu']
    if not os.path.exists(AUDIO_PATH):
        os.mkdir(AUDIO_PATH)
    for word in table:
        try:
            audio = tts(word, lang='ro')
            src = f'audio/{word}.mp3'
            dst = f'audio/{word}.wav'
            audio.save(src)
            sound = AudioSegment.from_mp3(src)
            sound.export(dst, format="wav")
            os.remove(src)
        except:
            print(word)
示例#12
0
	def falar(self,afirmacao):
		voice = tts(afirmacao, lang='pt')
		voice.save('ensaio1.mp3')
		Popen(['cvlc', 'ensaio1.mp3'])