0

I AM FACING THE PROBLEM IN THIS PROJECT. THIS PROJECT WAS PROGRAMMED BY MY FRIEND BUT I NEED IT SO, HE GAVE ME BY SAVING THE FILE AND HE SEND THAT FILE FROM MAIL.

IT WAS RUNNING IN HIS PC WITHOUT ANY ERRORS BUT WHEN RUN THE PROGRAM IT DOSE'NT WORK .

from gtts import gTTS

import os

from playsound import playsound

from datetime import date

from datetime import datetime

playsound('welcome.mp3')

playsound('req.mp3')

Initialize the recognizer

r = sr.Recognizer()

Function to convert text to

speech

#def SpeakText(command):6

# Initialize the engine

engine = pyttsx3.init()

#engine.say(command)

#engine.runAndWait()

def hindi(cmmd):

speak=gTTS(text=cmmd, lang="hi", slow=False)

speak.save('vc.mp3')

playsound('vc.mp3')

os.remove('vc.mp3')

Loop infinitely for user to

speak

while(1):

# Exception handling to handle

# exceptions at the runtime

try:

     

    # use the microphone as source for input.

    with sr.Microphone() as source2:

         

        # wait for a second to let the recognizer

        # adjust the energy threshold based on

        # the surrounding noise level

        r.adjust_for_ambient_noise(source2, duration=0.2)

         

        #listens for the user's input

        audio2 = r.listen(source2)

         

        # Using google to recognize audio

        MyText = r.recognize_google(audio2 , language='hi-In')

        MyText = MyText.lower()



        print(MyText)

        hindi(MyText)

        if MyText=="आज क्या तारीख है":

            #today = date.today()

            #d1 = today.strftime("%d %b %Y")

            d1=datetime.now()

            a=d1.strftime("%d %b %Y %H:%M")

            #a=(f"{a}")

            print(a)

            hindi(a)

        if MyText=="आपको किसने बनाया":

            print("मुझ को बनाने वाले का नाम अंशुल कुमार है")

            hindi("मुझ को बनाने वाले का नाम अंशुल कुमार है")

        if MyText=="तुमको किसने बनाया":

            print("मुझ को बनाने वाले का नाम अंशुल कुमार है")

            hindi("मुझ को बनाने वाले का नाम अंशुल कुमार है")

            

except sr.RequestError as e:

    print("Could not request results; {0}".format(e))

     

except sr.UnknownValueError:

    print("...........")`

`

KONKPIT
  • 19
  • 2
  • Do you have gTTS installed? If the error looks something like `ModuleNotFoundError: No module named 'gTTS'`, then it's because the module isn't installed. Could you add the specific error that the program gives to the question? – Jaffa Nov 30 '22 at 17:26
  • YES gTTS IS INSTALLED . " THERE IS N0 MODULE BOT FIND ERROR" HERE IS AN EXEPTION ERROR NOTED AS 275 – KONKPIT Dec 01 '22 at 13:32
  • Is welcome.mp3 in the same directory as the code? It looks like ‘PlaybackException Error 275’ might refer to a file not found – Jaffa Dec 01 '22 at 15:42

0 Answers0