Speech is the most common means of communication and the majority of the population in the world relies on speech to communicate with one another. Speech recognition system basically translates spoken languages into text. There are various real-life examples of speech recognition systems. For example, Apple SIRI which recognize the speech and truncates into text.
python libraries: pip install SpeechRecognition
python libraries: pip install SpeechRecognition
Convert an audio file into text
Steps:
- Import Speech recognition library
- Initializing recognizer class in order to recognize the speech. We are using google speech recognition.
- Audio file supports by speech recognition: wav, AIFF, AIFF-C, FLAC. I used ‘wav’ file in this example
- I have used ‘taken’ movie audio clip which says “I don’t know who you are I don’t know what you want if you’re looking for ransom I can tell you I don’t have money”
- By default, google recognizer reads English. It supports different languages, for more details please check this documentation.
\
Python Code :
import speech_recognition as sr
r = sr.Recognizer()
audio_file = sr.AudioFile("test.wav")
with audio_file as source:
r.adjust_for_ambient_noise(source)
audio = r.record(source)
result = r.recognize_google(audio)
with open("test.txt",mode ="w") as file:
file.write("Recognized text:")
file.write("\n")
file.write(result)
print("Hurray! conversion is complete")
Thank You ;d
hi! i got a little problem, the program tell me this line " raise RequestError("recognition request failed: {}".format(e.reason))" i dont know what i have to do, but i follow step by step the video, please help
ReplyDelete