Skip to content

Instantly share code, notes, and snippets.

View zakirangwala's full-sized avatar
🐛
squashing bugs

Zaki Rangwala zakirangwala

🐛
squashing bugs
View GitHub Profile
@zakirangwala
zakirangwala / listen.py
Last active September 23, 2020 13:06
Tutorial code : Listen Function
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)
@zakirangwala
zakirangwala / speak.py
Last active September 23, 2020 12:33
Tutorial code : Speak Function using the gTTS package
# 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")
@zakirangwala
zakirangwala / speak.py
Last active September 23, 2020 12:32
Tutorial code : Speak Function using the pyttsx3 package
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)