RENAME A FILE WITH VOICENOTE

Please if you like my content Please do not forget to support this channel on PayPal now for $1 only! Or less 


 while True:


try:

import os
import speech_recognition as sr
import pyttsx3




# Absolute path of a file

input0 = input("Write the directory to your file only! ")

# Initialize the recognizer
r = sr.Recognizer()

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)
MyText = MyText.lower()


inpuut = MyText
print(MyText)

old_name = input0

space1 = (len(old_name))

old_name = input0 [:space1] + inpuut

r = sr.Recognizer()

with sr.Microphone() as source1:

# wait for a second to let the recognizer
# adjust the energy threshold based on
# the surrounding noise level
r.adjust_for_ambient_noise(source1, duration=0.2)

# listens for the user's input
audio1 = r.listen(source1)

# Using google to recognize audio
MyText1 = r.recognize_google(audio1)
MyText1 = MyText1.lower()


inputt2 = (MyText1)
print(MyText1)

new_name = input0 [:space1] + inputt2



# Renaming the file
os.rename(old_name, new_name)
print("Name has been changed!")

except FileNotFoundError:
print("File Not Found Or Wrong Directory! Please input the correct details!")

except sr.RequestError as e:
print("Could not request results; {0}".format(e))

except sr.UnknownValueError:
print("unknown error occured")

No comments:

Post a Comment

Drawing App For Kivy

  Below here is the source code for Drawing Application for kivy. Please if you like this content.  Don't forget to Subscribe to my YouT...