Speech Recognition | Python Program
Speech recognition:
Tips:
1.Open your terminal or command prompt type "pip install speechRecognition".
2.Check your internet connection.
3.Save a .wav extension recorded audio file name as "sound" in my document.
4.Then, type under below code.
Code:
import speech_recognition as sr
AUDIO_FILE=('sound.wav')
r=sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
audio=r.record(source)
try:
print("audio file contain:\n"+r.recognize_google(audio))
except sr.UnknownValueError:
print("Not recog")
except sr.RequestError:
print("Data not get")
---------------------------------------------------------------------------------------------------------------------------
Thank you for visiting. Comment for response!
I am using ubuntu 18.04 and i don't have 'my document' folder as like windows, then where should i keep my audio file..??
ReplyDeleteFor Ubuntu:
DeleteIn second line of code
rewrite:
AUDIO_FILE=('C:\Users\"name of your computer"\Desktop\sound.wav')
or
AUDIO_FILE=('/home/"name of your computer"/Desktop/sound.wav')
I don't have a home folder too. Although i understood what you are trying to say. Thank you.
Delete1. Open one terminal and type "cd /" , you will be in system directory. From there navigate to the folder in which you have your audio file and that will be exact path which you gona be using in the program.
ReplyDelete2. You can also try be keep the audio file in the same folder in which you kept your program (example.py) file.
Hope this helps.