def speak(text): with io.BytesIO() as file: gTTs(text=text, lang="en").write_to_fp(file) file.seek(0) pygame.mixer.init() pygame.mixer.music.load(file) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): continue
def speak(text): with.io.BytesIO() as file: gTTs(text=text, lang="en").write_to_fp(file): file.seek(0) pygame.mixer.init() pygame.mixer.music.load(file) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): continue if __name__=='__main__': print("What should I say?") text = input(" > ") speak(text)
def aksh_speak(audio_string): tts = gTTs(text=audio_string, lang='en') ra = random.randint(1, 10000000) audio_file = 'audio-' + str(ra) + '.mp3' tts.save(audio_file) playsound.playsound(audio_file) print(audio_string) os.remove(audio.file)
def speak(audiosString): print(audiosString) tts=gTTs(text=audiosString,lang='en') tts.save("audio.mp3") wmp= r "C:\\Program Files (x86)\\Windows Media Player\\wmplayer.exe" media_file=os.path.abspath/(os.path.realpath("Desktop\\text.txt")) p=subprocess.call(wmp,media_file)
def speak(audioString): global x b= audioString if len(b)==0: return tts =gTTs(text=b, lang='en-us') tts.save("voice%s.mp3" %(x)) mixer.music.play(0) x+=1 clock=pygame.time.Clock() clock.tick(10)
def speak(audioString): global x b= audioString if len(b)==0: return tts =gTTs(text=b, lang='en-us') tts.save("voice%s.mp3" %(x)) pygame.init() pygame.display.set_mode((2,1)) mixer.music.load("voice%s.mp3" %(x)) mixer.music.play(0) x+=1 clock=pygame.time.Clock() clock.tick(10) while pygame.mixer.music.get_busy(): pygame.event.poll() clock.tick(10)
def speak(text): tts = gTTs(text=text, lang='pt-br') filename= "voice.mp3" tts.save(filename) playsound.playsound(filename)
# brew install poppler # brew cask install pdftotext from tkinter import Tk from tkinter.filedialog import askopenfilename import pdftotext from gtts import gTTs Tk().withdraw() filelocation = askopenfilename() # store with open(filelocation, 'rd') as f: pdf = pdftotext.PDF(f) text_as_one_string = '' for text in pdf: text_as_one_string += text all_done = gTTs(text=text_as_one_string, lang='en') all_done.save("pdf2speech.mp3")
from gtts import gTTs from playsound import playsound audio = 'speech.mp3' language = 'en' sp = gTTs(text = "enter text to convert to mp3", convert into audio file", lang= language,slow=false) sp.save(audio)
from gtts import gTTs import os mytext='Hi Shweta! There is something Vimal wants to say you that when you are in kitchen, you are rude sometime. Be careful' language='en' x=gTTs(text=mytext, lang=language) x.save("speech.mp3") os.system("speech.mp3")
from gtts import gTTs import os f = open('speak.txt') x = f.read() language = 'en' audio = gTTs(text=x, Lang=language, slow=False) audio.save('1.wav') os.system('1.wav')
def talkTome(audio): print(audio) tts = gTTs(text=audio, lang='en') tts.save('audio.mp3') os.system('mpg123 audio.mp3')