This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import speech_recognition as sr | |
# Listen to user input | |
def listen(): | |
r = sr.Recognizer() | |
with sr.Microphone() as source: | |
speak("I'm Listening") | |
print("Listening...") | |
r.pause_threshold = 1 | |
r.adjust_for_ambient_noise(source, duration=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import required modules for Text to speech conversion | |
from gtts import gTTS | |
import playsound | |
import os | |
#Speak Function | |
def speak(): | |
engine = gTTS(text='Hello World', lang='en', slow=False) | |
engine.save("speech.mp3") | |
playsound.playsound("speech.mp3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyttsx3 | |
# Initialize Text to Speech | |
engine = pyttsx3.init('sapi5') | |
voices = engine.getProperty('voices') | |
engine.setProperty('voice', voices[1].id) | |
# Speak Function | |
def speak(audio): | |
engine.say(audio) |
NewerOlder