Oct-05-2020, 10:28 AM
I fixed the audio now its not closing after i speak but i have code there 'if 'how are you' in text
speak i am fine that works very well but when i say second time how are you only prints to terminal but doesnt speak back again also there is other if 'DC' in text print 'dc link' this also works in first time but second time when i say Dc doesnt do anything i dont know why can you help me
speak i am fine that works very well but when i say second time how are you only prints to terminal but doesnt speak back again also there is other if 'DC' in text print 'dc link' this also works in first time but second time when i say Dc doesnt do anything i dont know why can you help me
import source as source import speech_recognition as sr import pyaudio import playsound import os import time from gtts import gTTS from selenium import webdriver from getpass import getpass from pynput.keyboard import Key, Controller def speak(text): tts = gTTS(text=text, lang="en") filename = "voice.mp3" tts.save(filename) playsound.playsound(filename) def get_audio(): r = sr.Recognizer() with sr.Microphone() as source: audio = r.listen(source) said = "" try: said = r.recognize_google(audio) print(said) except Exception as e: print("Expection:" + str(e)) return said text = get_audio() while "DC" in text: print("https://discord.gg/RjnpzX3") time.sleep(4) while "how are you" in text: speak("I am fine ") while True: if "" in text: get_audio()