Python Text to Speech | Speech to Text | Play Mp3 | Record Audio - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript Python Text to Speech | Speech to Text | Play Mp3 | Record Audio - Supercoders | Web Development and Design | Tutorial for Java, PHP, HTML, Javascript

Breaking

Post Top Ad

Post Top Ad

Thursday, February 27, 2020

Python Text to Speech | Speech to Text | Play Mp3 | Record Audio

Python Text to Speech | Speech to Text | Play Mp3 | Record Audio


Python Text to Speech | Speech to Text | Play Mp3 | Record Audio





Python Text to Speech | Speech to Text | Play Mp3 | Record Audio

Tutorial Cover:
1.How to Play Mp3 in Python
2.Pygame Play Mp3
3.Record Audio in Python
4.Python Text to Speech Example
5.Python Speech to Text Example



Join Our Telegram Channel to Stay Updated : https://t.me/supercoders




Text To Speech Code : 

import pygame
from gtts import gTTS
text="Hello Python Text to Speech Tutorial"
language="en"
obj=gTTS(text=text,lang=language,slow=False)
obj.save("audio.mp3")
pygame.mixer.init()
pygame.mixer.music.load(open("audio.mp3","rb"))
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
print("Playing..")
print("Played")
Speech to Text Code : 

import speech_recognition as speech
audio_text=""
read_audio=speech.Recognizer()
with speech.Microphone() as input_source:
print("Speak : ")
audio=read_audio.listen(input_source)
try:
audio_text=read_audio.recognize_google(audio)
print("You Said : "+audio_text)
except:
print("Error Occured")
Play Mp3 Code : 
import pygame
from time import sleep
pygame.mixer.init()
pygame.mixer.music.load(open("demo.mp3","rb"))
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
print("Playing..")
print("End Program")
view raw PythonPlayMp3.py delivered with ❤ by emgithub

Record Audio Code : 

import sounddevice as sound_device
from scipy.io.wavfile import write as audio_write
fs=44100
seconds=15
recording=sound_device.rec(int(seconds*fs),samplerate=fs,channels=2)
sound_device.wait()
audio_write("recording.wav",fs,recording)

No comments:

Post a Comment

Post Top Ad