def iot(url): response = requests.get(url) print(response.text) myaud=gtts(text=str(response.text),lang='en-uk',slow=False) name=random.randint(1,10000000) myaud.save(str(name) +".mp3") playsound.playsound(str(name) +".mp3")
def generate_audio(text): tts = gtts(text=text, lang=lang.code, slow=False) assets_path = '../client/src/assets/audio/' file_name = text + ".mp3" folder_path = assets_path + name + "/" + file_name tts.save(folder_path)
def speak(audio_string): tts = gtts(text=audio_string, lang='en') r = random.randint(1,20000000) audio_file = 'audio' + str(r) + '.mp3' tts.save(audio_file) playsound.playsound(audio_file) print(f"devpro: {audio_string}") os.remove(audio_file)
async def say(ctx, *, text): message = gtts(text) message.save('tts.mp3') channel = ctx.message.channel user = ctx.message.author if user.voice is None: await channel.send('Join a voice channel first') return voice_channel = user.voice.channel try: voice_client = await voice_channel.connect() except: pass ctx.guild.voice_client.play(discord.FFmpegPCMAudio('tts.mp3'))
def say(stringToRead): tts = gtts(text=repr(stringToRead), lang="en") tts.save("tts.mp3") mixer.music.load("tts.mp3") mixer.music.play()
# takes command line argument for file name card_file = sys.argv[1] # takes command line argument for the directory name where the mp3 files will # be stored, and makes the directory if it does not exist already directory = sys.argv[2] if not os.path.exists(directory): os.makedirs(directory) # prints file name to command line print "The subject of these flashcards are: ", card_file # opens file with name defined on the command line f = open(card_file) # counts the number of lines in the file num_lines = sum(1 for num_lines in open(card_file)) # opens an empty list, then fills it with each line in the text file my_list = list(f) length = len(my_list) # prints the number of 'flashcards' tp the command line q_num = num_lines / 3 print "my_list is", length, " and the number of questions is: ", q_num # closes the file f.close() for b in range(q_num): text = str(my_list[3 * b + 1] + my_list[3 * b + 2]) name = str(my_list[3 * b]) + '.mp3' soundbite = gtts(text, lang='en') soundbite.save(directory + "/" + name)
# takes command line argument for file name card_file = sys.argv[1] # takes command line argument for the directory name where the mp3 files will # be stored, and makes the directory if it does not exist already directory = sys.argv[2] if not os.path.exists(directory): os.makedirs(directory) # prints file name to command line print ("The subject of these flashcards are: ",card_file) # opens file with name defined on the command line f = open(card_file) # counts the number of lines in the file num_lines = sum(1 for num_lines in open(card_file)) # opens an empty list, then fills it with each line in the text file my_list = list(f) length = len(my_list) # prints the number of 'flashcards' tp the command line q_num = num_lines/3 print ("my_list is",length," and the number of questions is: ",q_num) # closes the file f.close() for b in range(q_num): text = str(my_list[3*b + 1]+my_list[3*b + 2]) name = str(my_list[3*b])+'.mp3' soundbite = gtts(text, lang='tr') soundbite.save(directory+"/"+name)
def playText(text): speech = gtts(text) speech.save("buffer.mp3") playsound("buffer.mp3") return 1
from gtts import gtts tts = gtts('hello') print(tts) # tts.save('C:\Users\taaviv\PointerAppAlyn\YOLOv3-Object-Detection-with-OpenCV\hello.mp3')
def transform(text, f='record.mp3', slow=False): assert isinstance(text, str) record = gtts(text=text, lang='en', slow=slow) record.save(f) return f
async def _say(self, ctx, text, lang = 'en'): message = gtts(text, lang = lang) message.save('cache/tts/tts.mp3') ctx.guild.voice_client.play(discord.FFmpegPCMAudio('cache/tts/tts.mp3'))
def speech(text): myaud = gtts(text=text, lang='en-uk', slow=False) name = random.randint(1, 10000000) myaud.save(str(name) + ".mp3") playsound.playsound(str(name) + ".mp3")
def audio_br(words, mp3name, language="pt"): teste = gtts(text=words, lang=language) teste.save("%s.mp3")
def tomp3(message, name, language="pt"): print(message) print(name) convert = gtts(text=message, lang=language) convert.save("%s.mp3" % os.path.join("./files", name))