Spaces:
Sleeping
Sleeping
File size: 874 Bytes
67965ba f808091 8c8ff11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
os.system("apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg")
import sounddevice as sd
import speech_recognition as sr
def takeCommand(audio):
r = sr.Recognizer()
with sr.AudioFile(
audio
) as source: # Replace "audio.wav" with the path to your .wav file
# print("Listening...")
audio_data = r.record(source)
try:
# print("Recognizing...")
query = r.recognize_google(audio_data, language="en-in")
print(f"User said: {query}")
return query
except sr.UnknownValueError:
print("Unable to recognize speech")
except sr.RequestError as e:
print(f"Error occurred: {e}")
return "Some error occurred. Sorry from Jarvis"
k=gr.Interface(fn=takeCommand, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
k.launch() |