コード例 #1
0
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
コード例 #2
0
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)
          
コード例 #3
0
ファイル: main.py プロジェクト: AkshRidlan/Speech_assistant
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)
コード例 #4
0
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)
コード例 #5
0
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)
コード例 #6
0
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)
コード例 #7
0
def speak(text):
    tts = gTTs(text=text, lang='pt-br')
    filename= "voice.mp3"
    tts.save(filename)
    playsound.playsound(filename)
コード例 #8
0
# 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")
コード例 #9
0
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)
コード例 #10
0
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")
コード例 #11
0
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')
コード例 #12
0
def talkTome(audio):
    print(audio)
    tts = gTTs(text=audio, lang='en')
    tts.save('audio.mp3')
    os.system('mpg123 audio.mp3')